John Asked: 2010-08-21 08:32:12 +0800 CST2010-08-21 08:32:12 +0800 CST 2010-08-21 08:32:12 +0800 CST use SED recursively in linux? 772 I want to implement the following command recursively sed -i 's/href=\"1\//href=\"\/1\//g' ./* so that it replaces all href="1 with href="/1 in all sub-directories. Is there a flag I can add to this command to achieve the results I want? linux unix shell sed 2 Answers Voted Best Answer topdog 2010-08-21T08:37:38+08:002010-08-21T08:37:38+08:00 find . -type f -print0 | xargs -0 sed -i 's/href=\"1\//href=\"\/1\//g' Pr0methean 2018-05-31T13:49:11+08:002018-05-31T13:49:11+08:00 Per https://stackoverflow.com/a/5130044/833771, if the target directory is a Git or SVN root, you should use: find . -not \( -name .svn -prune -o -name .git -prune \) -type f -print0 | xargs -0 sed -i 's/href=\"1\//href=\"\/1\//g'
Per https://stackoverflow.com/a/5130044/833771, if the target directory is a Git or SVN root, you should use:
find . -not \( -name .svn -prune -o -name .git -prune \) -type f -print0 | xargs -0 sed -i 's/href=\"1\//href=\"\/1\//g'