linux - Changing a line in multiple files -
i have many files, file0
file3100
. want add ###
1 line in each file.
the line
generated trjconv : pteg1 t= 8100.00000
should be
###generated trjconv : pteg1 t= 8100.00000
the time (t
) in each file different. how can add ###
each file in once , time (t
) still same in each file before adding?
here tried:
#!/bin/bash # loop inp files in current dir framefile in frame*.inp; sed -i -r -e 's/generated trjconv : pteg-1 t=.+/###generated trjconv : pteg-1 t=.+/g' ${framefile} fi done
a simple perl 1 liner job:
perl -pi -e 's/generated trjconv : pteg1 t=/###$&/' file*
this replace generated trjconv : pteg1 t=
###generated trjconv : pteg1 t=
within files have names begining file
Comments
Post a Comment