Sponsored Content
Top Forums UNIX for Beginners Questions & Answers How to simulate column command in Solaris? Post 303040492 by drl on Wednesday 30th of October 2019 08:50:39 AM
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
 

9 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

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. 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

7. 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

8. 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

9. 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
All times are GMT -4. The time now is 07:27 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy