How to simulate column command in Solaris?


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers How to simulate column command in Solaris?
# 1  
Old 10-09-2019
How to simulate column command in Solaris?

Hi,

Does anyone know how to have a similar output like below on Solaris without using column?
The output below is on Linux that uses the column and there is no column command in Solaris.

Code:
$ sort /tmp/x.txt | uniq | column -c 50
csfd0   csfd5   mchd11  mchp1   mpeq2   nocd20
csfd1   csfd8   mchd12  mcht1   mpet1   nocd3
csfd10  csfd9   mchd15  mcht11  nocd0   nocd5
csfd11  csft1   mchd2   mcht3   nocd1   nocd8
csfd12  csft11  mchd20  mped0   nocd10  nocd9
csfd15  csft3   mchd3   mped1   nocd11  nocp1
csfd2   mchd0   mchd5   mped10  nocd12  noct1
csfd20  mchd1   mchd8   mped15  nocd15  noct11
csfd3   mchd10  mchd9   mped20  nocd2   noct3

Found this command via Googling. This is more or less what am after but I want to put more spaces between columns though? Any tips on how to do this?

Code:
$: sort /tmp/x.txt | uniq | paste -s -d"\t\t\t\t\t\t\t\\t\n" -
csfd0   csfd1   csfd10  csfd11  csfd12  csfd15  csfd2   csfd20  csfd3
csfd5   csfd8   csfd9   csft1   csft11  csft3   mchd0   mchd1   mchd10
mchd11  mchd12  mchd15  mchd2   mchd20  mchd3   mchd5   mchd8   mchd9
mchp1   mcht1   mcht11  mcht3   mped0   mped1   mped10  mped15  mped20
mpeq2   mpet1   nocd0   nocd1   nocd10  nocd11  nocd12  nocd15  nocd2
nocd20  nocd3   nocd5   nocd8   nocd9   nocp1   noct1   noct11  noct3


Last edited by newbie_01; 10-10-2019 at 07:39 AM.. Reason: More information
# 2  
Old 10-10-2019
You should post the contents of your original data (in the file below):

Code:
/tmp/x.txt

... if you need expert help.
# 3  
Old 10-30-2019
Hi.

In the interest of completion, here is one solution: use pr. The data file had 54 lines in it, so I used a same-length data file with this script:
Code:
#!/usr/bin/env bash

# @(#) s1       Demonstrate command "pr" in place of "column".

# Utility functions: print-as-echo, print-line-with-visual-space, debug.
# export PATH="/usr/local/bin:/usr/bin:/bin"
LC_ALL=C ; LANG=C ; export LC_ALL LANG
pe() { for _i;do printf "%s" "$_i";done; printf "\n"; }
pl() { pe;pe "-----" ;pe "$*"; }
em() { pe "$*" >&2 ; }
db() { ( printf " db, ";for _i;do printf "%s" "$_i";done;printf "\n" ) >&2 ; }
db() { : ; }
C=$HOME/bin/context && [ -f $C ] && $C specimen pr align

FILE=${1-data1}

# Utility functions: print-as-echo, print-line-with-visual-space.
pe() { for _i;do printf "%s" "$_i";done; printf "\n"; }
pl() { pe;pe "-----" ;pe "$*"; }

pl " Input data file $FILE:"
specimen $FILE

pl " Results, pr, vertically:"
pr -t -5 data1

pl " Results, pr, horizontally (\"-a: across\"):"
pr -t -5 -a data1

pl " Results, /usr/xpg4/bin/pr vertically:"
/usr/xpg4/bin/pr -t -5 data1

pl " Results, pr, horizontally (\"-a: across\") into align -g: wide gutter:"
pr -t -4 -a data1 |
align -g 10

exit 0

producing:
Code:
$ ./s1

Environment: LC_ALL = C, LANG = C
(Versions displayed with local utility "version")
OS, ker|rel, machine: SunOS, 5.11, i86pc
Distribution        : Solaris 11.3 X86
bash GNU bash 4.1.17
specimen (local) 1.17
pr - ( /usr/bin/pr, 2016-04-10 )
align 1.7.0

-----
 Input data file data1:
Edges: 5:0:5 of 54 lines in file "data1"
one
two
three
four
five
   ---
fifty
fifty-one
fifty-two
fifty-three
fifty-four

-----
 Results, pr, vertically:
one           twelve        twenty-three  thirty-four   forty-five
two           thirteen      twenty-four   thirty-five   forty-six
three         fourteen      twenty-five   thirty-six    forty-seven
four          fifteen       twenty-six    thirty-seven  forty-eight
five          sixteen       twenty-seven  thirty-eight  forty-nine
six           seventeen     twenty-eight  thirty-nine   fifty
seven         eighteen      twenty-nine   forty         fifty-one
eight         nineteen      thirty        forty-one     fifty-two
nine          twenty        thirty-one    forty-two     fifty-three
ten           twenty-one    thirty-two    forty-three   fifty-four
eleven        twenty-two    thirty-three  forty-four

-----
 Results, pr, horizontally ("-a: across"):
one           two           three         four          five
six           seven         eight         nine          ten
eleven        twelve        thirteen      fourteen      fifteen
sixteen       seventeen     eighteen      nineteen      twenty
twenty-one    twenty-two    twenty-three  twenty-four   twenty-five
twenty-six    twenty-seven  twenty-eight  twenty-nine   thirty
thirty-one    thirty-two    thirty-three  thirty-four   thirty-five
thirty-six    thirty-seven  thirty-eight  thirty-nine   forty
forty-one     forty-two     forty-three   forty-four    forty-five
forty-six     forty-seven   forty-eight   forty-nine    fifty
fifty-one     fifty-two     fifty-three   fifty-four

-----
 Results, /usr/xpg4/bin/pr vertically:
one           twelve        twenty-three  thirty-four   forty-five
two           thirteen      twenty-four   thirty-five   forty-six
three         fourteen      twenty-five   thirty-six    forty-seven
four          fifteen       twenty-six    thirty-seven  forty-eight
five          sixteen       twenty-seven  thirty-eight  forty-nine
six           seventeen     twenty-eight  thirty-nine   fifty
seven         eighteen      twenty-nine   forty         fifty-one
eight         nineteen      thirty        forty-one     fifty-two
nine          twenty        thirty-one    forty-two     fifty-three
ten           twenty-one    thirty-two    forty-three   fifty-four
eleven        twenty-two    thirty-three  forty-four

-----
 Results, pr, horizontally ("-a: across") into align -g: wide gutter:
one                   two                   three                 four
five                  six                   seven                 eight
nine                  ten                   eleven                twelve
thirteen              fourteen              fifteen               sixteen
seventeen             eighteen              nineteen              twenty
twenty-one            twenty-two            twenty-three          twenty-four
twenty-five           twenty-six            twenty-seven          twenty-eight
twenty-nine           thirty                thirty-one            thirty-two
thirty-three          thirty-four           thirty-five           thirty-six
thirty-seven          thirty-eight          thirty-nine           forty
forty-one             forty-two             forty-three           forty-four
forty-five            forty-six             forty-seven           forty-eight
forty-nine            fifty                 fifty-one             fifty-two
fifty-three           fifty-four

If you can have root access, you can use pkgutil to install column:
Code:
pkgutil -h
...
Example: pkgutil -i CSWwget (install wget and its dependencies)

Written and maintained by Peter Bonivart. Web site: http://pkgutil.net.

Code:
$ pkgutil -a | grep column
column               CSWcolumn            8.1,REV=2005.03.06

Best wishes ... cheers, drl
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Simulate enter key

I have a popup window that appears on every boot up. I would like to have it dismissed automatically each time instead of having to hit the enter key. I thought I could write a script that would execute on startup. I tried this xdotool key return andy@7_~/Downloads$ xdotool key ... (7 Replies)
Discussion started by: drew77
7 Replies

2. Red Hat

Simulate Storage

Hello, I wanted to simulate SAN on my VMware PLayer running RHEL. Is there any tool that can be used to simulate storage setup for learning/testing? THanks, (1 Reply)
Discussion started by: ikn3
1 Replies

3. UNIX for Dummies Questions & Answers

Sort command in one column and not effect to another column

If my data is numerical : 1 = 101 2 = 102 3 = 104 4 = 104 7 = 103 8 = 103 9 = 105 I need the result like below: 1 = 101 2 = 102 3 = 103 4 = 103 7 = 104 8 = 104 9 = 105 (4 Replies)
Discussion started by: GeodusT
4 Replies

4. Shell Programming and Scripting

awk command to print only selected rows in a particular column specified by column name

Dear All, I have a data file input.csv like below. (Only five column shown here for example.) Data1,StepNo,Data2,Data3,Data4 2,1,3,4,5 3,1,5,6,7 3,2,4,5,6 5,3,5,5,6 From this I want the below output Data1,StepNo,Data2,Data3,Data4 2,1,3,4,5 3,1,5,6,7 where the second column... (4 Replies)
Discussion started by: ks_reddy
4 Replies

5. Shell Programming and Scripting

command for converting 4 column data to 1 column

dear friends I want to convert four column data to one column data. For example: from 1, 2, 3, 4 5, 6, 7, 8to 1 2 3 4 5 6 7 8what is the general command for that type of convertion. thanks (5 Replies)
Discussion started by: rpf
5 Replies

6. Programming

Tool to simulate non-sequential disk I/O (simulate db file sequential read) in C POSIX

Writing a Tool to simulate non-sequential disk I/O (simulate db file sequential read) in C POSIX I have over the years come across the same issue a couple of times, and it normally is that the read speed on SAN is absolutely atrocious when doing non-sequential I/O to the disks. Problem being of... (7 Replies)
Discussion started by: vrghost
7 Replies

7. UNIX for Advanced & Expert Users

Simulate CRON job

Does anyone know how I can simulate a cron job execution via UNIX scripting or is there a command/tool that simulate this? I have a file I called "appSchedule.txt", it contains below lines: 00 03 * * 1-6 RED start 00 06 * * 0 RED start 00 21 * * * RED stop 00 03 * * 1-6 ... (1 Reply)
Discussion started by: Orbix
1 Replies

8. UNIX for Dummies Questions & Answers

Newbie: Simulate unix on my pc

Hi, i am new with unix. Just came back from a course, unix basics for aix. So for me to practice, i want to install a simulation program for unix om my Windows Xp pc. Dual boot must it be. Does anybody have a suggestion for this dummy??? Thnx! Paul (5 Replies)
Discussion started by: welbp00
5 Replies

9. IP Networking

Simulate 'try again' case

Hi, I was searching thro the topic and could not find a thread which zeroes in on the case i'm trying to simulate. Basically I have a need to simulate DNS Try again cases, without bringing the dns_sever down (by manipulating the entries in /etc/resolv.conf under 'nameserver' tag). I am so... (5 Replies)
Discussion started by: srinivasan_85
5 Replies
Login or Register to Ask a Question