Samya Maiti
Samya Maiti

Reputation: 21

Remove substring in file using sed command

Remove substring in a file using sed command in shell

Eg.

cat TR

SAM9001,SAM9002,SAM9005


**Output:**

9001,9002,9005

Upvotes: 0

Views: 384

Answers (2)

pLumo
pLumo

Reputation: 407

using grep:

grep -o "[0-9]*" TR

Add | paste -sd, to make it comma-separated.

Upvotes: 0

Gautam
Gautam

Reputation: 1932

You can try this :

sed -i 's/SAM//g' TR

Upvotes: 1

Related Questions