Column for unix


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Column for unix
# 8  
Old 09-29-2008
Java? That's an awk script.

Could could put it on one line and use no comments and shorter variable names if you wish, e.g.

Code:
ls | awk 'BEGIN{if(!(w>0))w=80}length>m{m=length}{a[NR]=$0}END{c=int(w/++m);for(i=1;i<=NR;i++){printf("%-"m"s",a[i]);if(!(i%c))print""}if(--i%c)print""}'

You could implement the same algorithm easily enough in pure shell code or perl if you preferred.

You may be thinking of something like ls | paste - - - - (to format ls output into four columns, but that won't adjust the column widths to make them line up.
# 9  
Old 09-30-2008
Quote:
Originally Posted by vbe
What about pr command, it can do columns (I used it a lot in my early days...)
I overlooked this post... yes, I think pr is probably the most sensible option.
# 10  
Old 09-30-2008
Question Samba 3.0.24 in SCO UnixWare 7.1.4

Please help me in troubleshooting my problem in Samba?
I tried to instal Samba 3.0.24 in our SCO UnixWare 7.1.4 but after installing the nmbd daemon is not running.
When i check the syslog from /var/adm, the following error appears:
Sep 30 13:04:22 unixeei nmbd[25169]: bind failed on port 137 socket_addr =0.0.0.0.



Thanks Smilie

Eric
# 11  
Old 09-30-2008
Please start your own thread.
# 12  
Old 10-01-2008
As I already mentionned, look at pr...
Code:
co:/home/vbe/wks $ cat gaga
1234567890
qwertzuiop
asdfghjkl
<yxcvbnm,.
co:/home/vbe/wks $ pr -c 3 gaga|more


Oct 01 10:48 2008  gaga Page 1


1234567890              asdfghjkl               <yxcvbnm,.
qwertzuiop


Last edited by vbe; 10-01-2008 at 05:52 AM.. Reason: spelling...
# 13  
Old 02-09-2009
column uses environment variable COLUMNS as a definition of the width of the output in characters ( example 80 ) unless -c is specified.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

UNIX script to compare 3rd column value with first column and display

Hello Team, My source data (INput) is like below EPIC1 router EPIC2 Targetdefinition Exp1 Expres rtr1 Router SQL SrcQual Exp1 Expres rtr1 Router EPIC1 Targetdefinition My output like SQL SrcQual Exp1 Expres Exp1 Expres rtr1 Router rtr1 Router EPIC1 Targetdefinition... (5 Replies)
Discussion started by: sekhar.lsb
5 Replies

2. UNIX for Advanced & Expert Users

Copy a column to another column in UNIX fixedwidth file

Hi All, I have a fixedwidth file of length 3000. Now i want to copy a column of 4 chars i.e( length 1678-1681) to column 1127 – 1171 to the same file. Please let me know how can i achive using a single command in fixed width file. Also source column length is 4 chars and target column length... (4 Replies)
Discussion started by: kiranparsha
4 Replies

3. UNIX for Dummies Questions & Answers

Reorder column in Unix

I have a flat file with the 3 columns and separate by tab delimiter, and the last column with special character. A B C D F G Now I would like to swap the third column with second column to following format: A B C D F G I know this cannot be done in Unix command with using cut... (3 Replies)
Discussion started by: newbie2011
3 Replies

4. UNIX for Dummies Questions & Answers

Copy column to another column in unix

Dear Gurus, I have a unix file 2 columns (# delimited) with the following data: ZTXX_CTBR1-ZBRAN1#ZTXX_CTBR1-ZBRAN_DESC# 01#CASH & CARRY# 02#DRUGSTORE - RX# 04#SUPERMARKET# 05#HYPERMARKET# 17#DRUGSTORE - NO RX# I would like to have a code that will do 2 things: 1. Delete the header... (16 Replies)
Discussion started by: chumsky
16 Replies

5. Shell Programming and Scripting

for each different entry in column 1 extract maximum values from column 2 in unix/awk

Hello, I have 2 columns (1st column has multiple entries but the corresponding values in the column 2 may be the same or different.) however I want to extract unique values for each entry in column 1 by assigning the max value from column 2 SDF4 -0.211654 SDF4 0.978068 ... (1 Reply)
Discussion started by: Diya123
1 Replies

6. Shell Programming and Scripting

Replacing the column value in Unix

Hello all, I have a file with below content.Its basically huge file but listing few of the content A0|SAL |bN |g10 | |20100611|G|1 M0|AL |bN |g10 | |20100611|K|2 n0|L |bN |g10 | |20100611|V|4... (5 Replies)
Discussion started by: j_panky
5 Replies

7. Shell Programming and Scripting

Match column 3 in file1 to column 1 in file 2 and replace with column 2 from file2

Match column 3 in file1 to column 1 in file 2 and replace with column 2 from file2 file 1 sample SNDK 80004C101 AT XLNX 983919101 BB NETL 64118B100 BS AMD 007903107 CC KLAC 482480100 DC TER 880770102 KATS ATHR 04743P108 KATS... (7 Replies)
Discussion started by: rydz00
7 Replies

8. Shell Programming and Scripting

Changing one column of delimited file column to fixed width column

Hi, Iam new to unix. I have one input file . Input file : ID1~Name1~Place1 ID2~Name2~Place2 ID3~Name3~Place3 I need output such that only first column should change to fixed width column of 15 characters of length. Output File: ID1<<12 spaces>>Name1~Place1 ID2<<12... (5 Replies)
Discussion started by: manneni prakash
5 Replies

9. UNIX for Advanced & Expert Users

Sorting in unix using column number

Hi All, Can anyone tell me how to sort data in a file using the “sort” command? Note that the records in the data file are not separated into fields. I know only the column positions of the data on which sorting should be done. For example say I've to sort based on the data present in between... (1 Reply)
Discussion started by: swat
1 Replies

10. UNIX for Dummies Questions & Answers

to delete a column in unix

Hai Please let me know the command in unix(command mode ) from a file that deletes the whole column (not 1st and last column )& replace with numbers starting from 1. Regards suneetha. (8 Replies)
Discussion started by: gaddesuneetha
8 Replies
Login or Register to Ask a Question