Hi I need a bash script that can search through a text file for all lines starting with 71502FSC1206 on every line it finds starting with this I need to place a letter F at the 127 position on that line.
Thanks
Paul
Hi I need a bash script that can search through a text file for all lines starting with 71502FSC1206 on every line it finds starting with this I need to place a letter F at the 127 position on that line.
Thanks
Paul
cat file | grep "^71502FSC1206" | sed 's/127/F/g'
Thanks for the reply but that did not work, I need it to place a Letter F at the 127th position on every line it finds that starts with 71502FSC1206
can you post the sample input file and expected output
---------- Post updated at 08:03 PM ---------- Previous update was at 07:59 PM ----------
try this...
awk '/71502FSC1206/{$0=substr($0,1,126)"F"substr($0,128,length($0))}1' input.txt
To make that change with sed:
sed '/^71502FSC1206/s/.\{126\}/&F/' file
With ed:
ed -s file <<'EOED'
g/^71502FSC1206/s/.\{126\}/&F/
w
q
EOED
Regards,
Alister
sed:
sed '/^71502FSC1206/s/./F/127'
--
Some awks can do this:
awk '/^71502FSC1206/{$127="F"}1' FS= OFS= infile
Many thanks everyone! really really appreciate the help, all working now