#! /bin/sh
# filename: replaceallme: replaceall
find . -type f -name '*.htm*' -print | while read i
do
sed 's|^|http:\/\/www.|g' $i > $i.tmp && mv $i.tmp $i
done

 This previous shell script recurses through the directory tree,
  finding only files in the directory (not symbolic links, which will
  be encountered by the shell command "for file in *.txt", above). To
  preserve file permissions and make backup copies, use the 2-line cp
  routine of the earlier script instead of "sed ... && mv ...". By
  replacing the sed command 's|foo|bar|g' with something like

     sed "s|$1|$2|g" ${i}.bak > $i

  using double quotes instead of single quotes, the user can also
  employ positional parameters on the shell script command tail, thus
  reusing the script from time to time. For example,

     replaceall East West
source: http://www.experts-exchange.com/Operating_Systems/Linux/Q_10515858.html

idem mais mieux

changer motifA et motifB ci-dessous
Trouver les fichiers et les stocker:
grep -l "DTD XHTML 1.0 Strict" */*/*/*.htm* >> ~/junk
vi ~/junk
:%s/^/vi -c "%s\/motifA\/motifB\/g" -c "wq" /g
source junk
(ou rendre junk executable puis ./junk)
  • info/remplacer_dans_plusieurs_repertoires_un_string.txt
  • Dernière modification: 2018/07/18 09:46
  • par radeff