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
# 8  
Old 11-25-2008
I get the desired output:

Code:
$ 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
# 9  
Old 11-26-2008
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.

Last edited by ulin; 11-26-2008 at 09:18 AM..
# 10  
Old 11-26-2008
Quote:
Originally Posted by ulin
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:

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

# 11  
Old 12-03-2008
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.
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