Originally Posted by pompadir
I need to change a specific word to another in several text files which located in one directory.
for example: change all the "AAAA" to
"BBBB" in the files that have ".txt"
extension in the /log directory.
I know that's easy, but I don't know how to do it...
for LIST in `ls *.txt`; do cp $LIST $LIST.bak; cat $LIST| sed 's/AAAA/BBBB/g'>$LIST; done
Basically for each file that can be seen using ls *.txt command
to test use
in a konsole
back each up file up by adding .bak to a copy.
load the text file with cat and pass it through sed to replace AAAA with BBBB
then dump it to the same file name variable $LIST.
to test the text replace in a konsole use
cat filename.txt| sed 's/AAAA/BBBB/g'