Extend the Output length of a row


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Extend the Output length of a row
# 1  
Old 11-23-2008
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.
# 2  
Old 11-23-2008
One way:

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

# 3  
Old 11-24-2008
perl:

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

awk:

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


Last edited by summer_cherry; 12-03-2008 at 05:51 AM..
# 4  
Old 11-24-2008
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.
# 5  
Old 11-24-2008
Quote:
Originally Posted by summer_cherry
perl:

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


Hi ,

Thanks for your post am doing my program in Shell script so am sticking on to it.
# 6  
Old 11-24-2008
Quote:
Originally Posted by ulin
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.
Use nawk, gawk or /usr/xpg4/bin/awk on Solaris.

Regards
# 7  
Old 11-25-2008
Quote:
Originally Posted by Franklin52
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
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash - delete from csv all the row if the first column is length >

Hi guys, i have a csv file like: USERID;COG;DESCR;FIL;OFF user001;user;test1;001;A01 user002;user;test2;002;A02 user0003;user;test3;003;A03 user004;user;test4;004;A04 user0005;user;test5;005;A05 etc.. I need to read line for line and, if value of first column is > 7 char (in this example... (4 Replies)
Discussion started by: kamose
4 Replies

2. Shell Programming and Scripting

awk to output the percentage of a field compared to length

The awk below using the sample input would output the following: Basically, it averages the text in $5 that matches if $7 < 30 . awk '{if(len==0){last=$5;total=$7;len=1;getline}if($5!=last){printf("%s\t%f\n", last,... (6 Replies)
Discussion started by: cmccabe
6 Replies

3. UNIX for Dummies Questions & Answers

Finding row number along with length of row

I have a fixed length file and I want to find out row number along with row length. I have a program that give me the line length if it satisfy the condition; but i would like to add row number as well? How do I do that? while IFS= read -r line; do if ; then echo ${line} echo... (8 Replies)
Discussion started by: princetd001
8 Replies

4. UNIX for Dummies Questions & Answers

Count on grep for more than two values in a row of fixed length file

I want to get count on number of records in a few folders by running grep command for more than two columns in a row of fixed length file. suppose if i have a fixed length file has 5 columns and I want to see the record counts for country =can and province = bc and time stamp <= 12 feb 2013... (14 Replies)
Discussion started by: princetd001
14 Replies

5. Shell Programming and Scripting

Column to row output

Hello All, i have a file with the contents like shown below Name = POLICY1 Selected = 1 Written = 0 Name = POLICY2 Selected = 6 Written = 8 Name = POLICY3 Selected = 4 Written = 26 I want the output to be... (5 Replies)
Discussion started by: vinredmac
5 Replies

6. Shell Programming and Scripting

extending the line length of nohup output

Hi I'm backgrounding matlab jobs using nohup. My foreground programs are written for an xterm that has 132 columns. When I use nohup and redirect the output to nohup.out, the default appears to be something like 72 columns, which breaks up my formatted screen output from matlab commands... (1 Reply)
Discussion started by: LeoSimon
1 Replies

7. Shell Programming and Scripting

convert a column to row output?

Getting tired of cut-and-paste...so I thought I would post a question. how do I change this column output to a single row? from this: # vgdisplay -v /dev/vgeva05 | grep dsk | awk '{print $3}' /dev/dsk/c6t0d5 /dev/dsk/c11t0d5 /dev/dsk/c15t0d5 /dev/dsk/c18t0d5 /dev/dsk/c7t0d5... (8 Replies)
Discussion started by: mr_manny
8 Replies

8. UNIX for Dummies Questions & Answers

Capping output redirection log file length

I am trying to write a script which will output notifications to a logfile, but I would like to cap the logfile to, let's say, 200 lines. Specifically I am using custom firmware, DD-wrt, on my router and I am implementing a script to connect to my work vpn. I have a loop that pings a computer... (2 Replies)
Discussion started by: joemommasfat
2 Replies

9. Shell Programming and Scripting

top output for six processes with the same name, output changed from column to row

Hi, I have a system under test, and I use a script that does a ps. The output, is in the following format, it's basically the timestamp, followed by the rss and vsize. 09:03:57 68404 183656 68312 181944 69860 217360 67536 182564 69072 183172 69032 199276 09:04:27 68752 183292 70000 189020... (5 Replies)
Discussion started by: Bloke
5 Replies

10. Shell Programming and Scripting

creating a fixed length output from a variable length input

Is there a command that sets a variable length? I have a input of a variable length field but my output for that field needs to be set to 32 char. Is there such a command? I am on a sun box running ksh Thanks (2 Replies)
Discussion started by: r1500
2 Replies
Login or Register to Ask a Question