|
Search Forums:
|
|||||||
| Forums | Register | Forum Rules | Linux and Unix Links | Man Pages | Albums | FAQ | Users | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
join two lines
I want to join this two lines but only when after him
I have nothing or a comma Yes, I know Jonesy, and I'll give him about one more minute. this two lines must become Yes, I know Jonesy, and I'll give him about one more minute. thank you very much |
| Sponsored Links | |
|
|
|
#3
|
||||
|
||||
|
Code:
sed '/[^[:punct:]],*$/{N;s/\n/ /;}' infileCode:
awk '/[^[:punct:]],*$/{getline $(NF+1)}1' infile |
| The Following User Says Thank You to Scrutinizer For This Useful Post: | ||
thailand (02-08-2012) | ||
|
#4
|
|||
|
|||
|
the input is like this
This is my cat my cat's name is betty This is my dog my dog's name is frank This is my fish my fish's name is george This is my goat my goat's name is adam when I use xargs then the output is my goat's name is adamge when I use sed or awk then the output is my cat's name is betty This is my dog y dog's name is frank my fish's name is george This is my goat y goat's name is adam but the output must be this -------------------------------------- This is my cat my cat's name is betty This is my dog my dog's name is frank This is my fish my fish's name is george This is my goat my goat's name is adam thank you |
| Sponsored Links | |
|
|
#5
|
||||
|
||||
|
I presume you mean the other way around.. See if this works: Code:
awk '/[^[:punct:]],*$/{getline $(NF+1)}NF' infileor perhaps even this (if every sentence is a paragraph that ends with an empty line).. Code:
awk '$1=$1' RS= infile |
| The Following User Says Thank You to Scrutinizer For This Useful Post: | ||
thailand (02-09-2012) | ||
| Sponsored Links | |
|
|
#6
|
|||
|
|||
|
try this Code:
xargs -L 2 < filename.txt |
| The Following 2 Users Say Thank You to tarun_agrawal For This Useful Post: | ||
Scrutinizer (02-09-2012), thailand (02-09-2012) | ||
| Sponsored Links | |
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| join 2 lines | maxim42 | Shell Programming and Scripting | 8 | 03-02-2010 07:22 PM |
| Join the lines | Beginer0705 | Shell Programming and Scripting | 8 | 09-30-2009 02:42 AM |
| join lines | repinementer | Shell Programming and Scripting | 2 | 09-19-2009 02:53 AM |
| how to join lines | glamo_2312 | UNIX for Dummies Questions & Answers | 8 | 09-16-2008 04:17 AM |
| join two lines together | tine | Shell Programming and Scripting | 4 | 12-12-2003 11:34 AM |
|
|