Extend the Output length of a row

hi all,

I use shell script to fetch some data's from my sybase database and i redirect my output to a file , i have some disorder in my file.my current o/p file looks like,

firstrecord|secondrecord|thirdrecord|fourthrecord|fivthrecord|s
ixhrecord|seventhrecord|

coulmnone|coulmntwo|coulmnthree|coulmnfour|coulmnfive|coul
mnsix|coulmnseven|

but my o/p needs to be in a single line

firstrecord|secondrecord|thirdrecord|fourthrecord|fivthrecord|sixhrecord|seventhrecord|
coulmnone|coulmntwo|coulmnthree|coulmnfour|coulmnfive|coulmnsix|coulmnseven|

am sure it is not query issue, Kindly adivice.Thanks in advance.

One way:

awk '!/\|$/ && NF{s=$0;getline;print s $0}' file

perl:

$/="\n\n";
open FH,"<content.txt";
@arr=<FH>;
map {s/\n//g} @arr;
print $_,"\n" foreach @arr;

awk:

awk '/^$/ { print "\n";next} {printf("%s",$0)}' filename 

Hi

when i tried to use your cmd

awk '!/\|$/ && NF{s=$0;getline;print s $0}' Del.csv

am getting an error message as
awk: syntax error near line 1
awk: bailing out near line 1

Kindly advise.

Hi ,

Thanks for your post am doing my program in Shell script so am sticking on to it.

Use nawk, gawk or /usr/xpg4/bin/awk on Solaris.

Regards

hi ,

now am getting an output like below, kindly help

                                                  firstrecord|secondrecord|thirdrec

ord|fourthrecord|fivthrecord|s
ixhrecord|seventhrecord|

                                                   coulmnone|coulmntwo|coulmn

three|coulmnfour|coulmnfive|coul
mnsix|coulmnseven|

but my output needs to like

firstrecord|secondrecord|thirdrecord|fourthrecord|fivthrecord|sixhrecord|seventhrecord|
coulmnone|coulmntwo|coulmnthree|coulmnfour|coulmnfive|coulmnsix|coulmnseven|

regards

I get the desired output:

$ cat file
firstrecord|secondrecord|thirdrecord|fourthrecord|fivthrecord|s
ixhrecord|seventhrecord|

coulmnone|coulmntwo|coulmnthree|coulmnfour|coulmnfive|coul
mnsix|coulmnseven|

$ awk '!/\|$/ && NF{s=$0;getline;print s $0}' file
firstrecord|secondrecord|thirdrecord|fourthrecord|fivthrecord|sixhrecord|seventhrecord|
coulmnone|coulmntwo|coulmnthree|coulmnfour|coulmnfive|coulmnsix|coulmnseven|
$

Regards

Hi

i apologize for that, i have made a mistake in my query,my output looks like ,there is a whitespace in the continuation of the first line to the second line, but i need the output in a single line

firstrecord|secondrecord|thirdrecord|fourthrecord|fivthrecord|s
(Whitespace)ixhrecord|seventhrecord|

coulmnone|coulmntwo|coulmnthree|coulmnfour|coulmnfive|coul
(Whitespace)mnsix|coulmnseven|

which would need to be like ,

firstrecord|secondrecord|thirdrecord|fourthrecord|fivthrecord|sixhrecord|seventhrecord|
coulmnone|coulmntwo|coulmnthree|coulmnfour|coulmnfive|coulmnsix|coulmnseven|

Kindly advice.

Try this:

awk '!/\|$/ && NF{s=$0;getline;sub(/^ /, "");print s $0}' file

Hi ,

Thanks you very much, the cmd worked fine for any file created with a tab in the second line. But as my file was generated through isql this cmd dint worked for me, as isql result has a default of 80 char, once i chaged the default column width it worked for me .

isql -w 250

this is the cmd used to set coulum width.

Thanks for your replies.