Matching newlines with sed, not working
Hi folks,
I need to make a fortune plain-text file from plain-text files, i.e. substitute every <newline><newline> occurrence in plain-text files with <newline>% <newline>. I tried to use sed as follows Quote:
An I also tried using the raw newline character Quote:
Quote:
\n seems to work only as substitution(2nd) argument. I'm using gnu sed 4.1.5. You may be able to save me the trouble of converting such files in first instance. Do you know where I can download fortunes with quotes about programming languages, software costruction, etc... found in SysProg's site? TIA Tavs |
Use $ instead of \n as pattern:
Code:
sed -e 's/$/\n%\n/g' myfile |
sed won't pass you the newline - try perl.
|
show a sample of your file and your output.
|
Wow, so much replies! Thanks a lot!
Here's the input, got from copy&paste quotes from SysProg site Quote:
Quote:
PS: I'm using sed 'cause I learnt reg-expression through emacs, lisp and java, thus I'm not used to quick&easy one-liner commands, and I know the sed substitute command only, so be really patient! :D |
All times are GMT -5. The time now is 05:46 PM. |