|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi All
I need a small help for the below format in making a small script in Perl or Shell. I have a file in which a single line entries are broken into three line entries. Eg: I have a pen and notebook. All i want is to capture in a single line in a separate file. eg: I have a pen and notebook. Thanks in Advance for your help. Regards Kalaiela |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
Code:
$ while read a; do echo -n "$a "; done < input.txt I have a pen and notebook. |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
Hi Kamraj
Could you pls explain me how your code works. Its not working in my machine.I got the output as below. > while read a; do echo -n "$a "; done < input.txt -n I have a -n pen and -n notebook. More over my input file is like below. I have a pen and notebook. I have a pen and notebook. Like this it is repeating with two blank lines in the middle. what i want is I have a pen and notebook. I have a pen and notebook. Thanks in Advance. |
|
#4
|
|||
|
|||
|
Code:
cat FILE
I have a
pen and
notebook.
I have a
pen and
notebook.
~
perl -00 -pe 's/\n/ /g; s/ $/\n/' FILE
I have a pen and notebook.
I have a pen and notebook. |
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
Code:
$ cat file I have a pen and notebook. $ perl -pe 's/\n/ /g;' file I have a pen and notebook. if you want output in another file, you can simplye redirect it Code:
$ perl -pe 's/\n/ /g;' file > file1 Njoy!!
|
| 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 |
| Multiple lines in a single column to be merged as a single line for a record | Bhuvaneswari | Shell Programming and Scripting | 1 | 08-11-2011 03:16 AM |
| Combine multiple lines in single line | The One | Shell Programming and Scripting | 8 | 10-26-2010 12:15 PM |
| Multiple lines into a single line | RickyC9999 | Shell Programming and Scripting | 4 | 02-22-2010 02:41 PM |
| Awk multiple lines with 3rd column onto a single line? | SoMoney | Shell Programming and Scripting | 4 | 12-06-2008 07:59 AM |
| replacing multiple lines with single line | siba.s.nayak | Shell Programming and Scripting | 3 | 05-28-2008 02:43 AM |
|
|