I have 1000 files with txt format, I want to
I want to replace the first line of each file which is "PUT KEYWORDS HERE" with my keywords which is "XYZ LET DDMIN=0.0 SCFCRT=1.D-10"
any idea
CodePudding user response:
sed -i "/PUT KEYWORDS HERE/c\XYZ LET DDMIN=0.0 SCFCRT=1.D-10" path/to/file/*.txt
CodePudding user response:
Try this
#!/bin/bash
files=$(ls -lA ./path | grep -v "total" | awk {'print $NF'})
for file in ${files[*]}
do
sed -i -e '1s/PUT KEYWORDS HERE/XYZ LET DDMIN=0.0 SCFCRT=1.D-10/' ./path/$file
done