A few points to add to the above about using
sed.
1) You can avoid having to escape any "
/"s in the expression by using a different delimiter. For the "
s" command, you can simply use a different character. For the range entries, you can use a different character if you precede the first one with a backslash. Any basic ascii character except null or newline can be used.
2) On the other hand,
sed treats the expressions as
regular expressions, and certain characters in those are special, such as the period. To match a literal "
." then, you need to escape it, or as I prefer, box it in a bracket expression.
3) You can edit the original file directly if you use the
-i option, at least with
gnu sed.
Code:
sed -i 's^/[.]svn^^' inputfile #remove substrings from lines (delimiter is "^")
sed -i '\@/[.]svn@d' inputfile #remove entire lines matching a substring (delimiter is "@")
Here are a few useful sed references:
http://www.grymoire.com/Unix/Sed.html
http://sed.sourceforge.net/grabbag/
http://sed.sourceforge.net/sedfaq.html
http://sed.sourceforge.net/sed1line.txt
You might also consider using
ed instead. It's a dedicated text editor and can manipulate files directly. The syntax is similar to
sed, but its delimiters are more primitive and only accept the backslash.
Code:
printf '%s\n' '% s/[/][.]svn//' 'w' | ed -s inputfile
printf '%s\n' 'g/[/][.]svn/d' 'w' | ed -s inputfile
How to use ed:
http://wiki.bash-hackers.org/howto/edit-ed
http://snap.nlc.dcccd.edu/learn/nlc/ed.html
(also read the info page)