I have a multi-line text file where each line has a format
..... Game #29832: ......
I want to add the character “1” to each number on each line (which is different on each line), does anyone know how to do this from the command line?
thank
Usage sed:
sed
cat file | sed -e 's/\(Game #[0-9]*\)/\11/'
sed -i -e 's/Game #[0-9]*/&1/' file
-iDesigned for in-place editing, which &means everything that matches the template. If you do not want to overwrite the file, omit the flag -i.
-i
&
sed 's/ Game #\([0-9]*\):/ Game #1\1:/' yourfile.txt
GNU awk
awk '{b=gensub(/(Game #[0-9]+)/ ,"\\11","g",$0); print b }' file