|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | 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
|
|||
|
|||
|
Arranging Haphazard output in readable format
Dear Friends, Need your help once again. I have a sql to download output in pipe separated format. Due to that output looks haphazard. E.G. Code:
$cat output.temp 123|456|789|0 67345123||3455|1 7124563|432343414||345324 By any was can we arrange it in tabular format for better readability? Please guide me. Thanks Anu. Last edited by Scott; 01-18-2013 at 04:15 AM.. Reason: Code tags |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
Code:
awk -F'|' '{for (i=1;i<=NF;i++){printf "%-20s", $i}}{printf "\n"}' file |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
one way is you can run your sql query to get the output in csv format. Or you can run a script on this output replace | with , and open the file in excel or any spreadsheet. That way you can see output in tabular format. Or just try following and open the file into spreadsheet. Code:
me@lappy:~/Documents/file$ cat tmp.txt 123|456|789|0 67345123|3455|1 7124563|432343414|345324 me@lappy:~/Documents/file$ sed -e s/\|/,/g tmp.txt 123,456,789,0 67345123,3455,1 7124563,432343414,345324 |
|
#4
|
|||
|
|||
|
Look if you have the column utility available on your system. Code:
$ cat output.temp 123|456|789|0 67345123||3455|1 7124563|432343414||345324 $ column -nt -s'|' output.temp 123 456 789 0 67345123 3455 1 7124563 432343414 345324 Edit: the -n option is a Debian GNU/Linux extension, so maybe not available to you - your manpage will tell. |
| Sponsored Links | |
|
|
#5
|
||||
|
||||
|
Hi. Using the perl utility align on the data in file data1: Code:
% align -s '/\|' -ar -j_ -g3 data1
123 456 789 0
67345123 3455 1
7124563 432343414 345324One can select the field separation pattern as "|', the alignment is right, the output separation is done with space characters, and the gutter is 3 spaces, so that numbers can be easily compared. There are generally appropriate defaults for these, but you can change them if desired, as illustrated See the page for details and download: align ? Freecode Best wishes .. cheers, drl |
| 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 |
| Need Help in arranging the output | Sudeep Bhattad | Shell Programming and Scripting | 4 | 10-25-2012 03:21 AM |
| help in extracting logs in readable format | eanne_may | UNIX for Dummies Questions & Answers | 1 | 08-29-2011 12:24 PM |
| vmstat in a better readable format | tom_k_mishra | UNIX for Dummies Questions & Answers | 1 | 03-29-2010 03:01 AM |
| file in malibox is readable format? | megh | HP-UX | 1 | 08-13-2008 01:13 PM |
| To convert multi format file to a readable ascii format | gaur.deepti | UNIX for Dummies Questions & Answers | 5 | 03-25-2008 03:03 PM |
|
|