Anique Awan
Anique Awan

Reputation: 3

How to change number to letters using sed command?

How i can change numbers to letters by using sed command linux

for example : if the longitude of numbers is 4 ,5 ,6 o 7 then change this number to abcd.(only sed)

123 1234 123445 125475585

result: 123 abcd abcd abcd

Thanks

Upvotes: 0

Views: 991

Answers (2)

Cyrus
Cyrus

Reputation: 88543

With GNU sed:

echo '123 1234 123445 125475585' | sed -E 's/\b[0-9]{4,9}\b/abcd/g'

Output:

123 abcd abcd abcd

Upvotes: 2

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798456

The easiest way is to use the map operation.

$ sed 'y/4567/abcd/' <<< '65423476512935'
cba23adcb1293b

Upvotes: 2

Related Questions