Hi again!
Sed is very difficult to understand for me...
I have a file like this
And I'm looking for this result
I found sed '$!N;s/\n/ /' => Put Line1 and Line2 together, Line3 and Line4...
I tried |sed '$!N;s/\n*\n/ /' but it didn't work...
Thanks for your help
PS:And if you have a nice documentation which explain sed with a lot of examples, because I really prefere to find the solution by myself...
It's regular expressions which give pople the most problems with sed -
see Dale Dougherty & Arnold Robbins 'sed & awk' book.
Actually awk works pretty well for your problem
awk ' NR%3 {printf("%s", $0); next}
!NR%3 {print $0} ' inputfile > newfile
which means
- if the line number % 3 is not zero print the line with no carriage return; skip to next line
- if the line number % 3 is zero print the line with a carriage return
Another one:
pr -3tas file.txt | sed 's/\t//g'
awk '{ORS=(NR%3)?S:RS}1' infile
Use gawk, nawk or /usr/xpg4/bin/awk on Solaris.
Hi, Castelior:
If no space is desired between lines:
sed '$!N;$!N;s/\n//g'
If you want a space between joined lines:
sed '$!N;$!N;s/\n/ /g'
or
sed '$!N;$!N;y/\n/ /'
Regards,
Alister
---------- Post updated at 02:44 PM ---------- Previous update was at 02:33 PM ----------
Woops! I just noticed that bit. Sorry for spoiling it for you. This link may help you in learning SED Sed - An Introduction and Tutorial
Best of luck,
Alister
Thanks everyone!
I gonna test it!
---------- Post updated at 08:43 AM ---------- Previous update was at 08:41 AM ----------
It looks great!!! thank you so much!