Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to print to get formatted columns 2

Status
Not open for further replies.

ogniemi

Technical User
Nov 7, 2003
1,041
PL
i get in result colums separated with spaces but it is not readable so good...

NSTRBLKSCHED - - - - -
NSTREVENT 50 50 50 50 50
NSTRPUSH 16 16 16 16 16
NSTRSCHED 0 0 0 0 0
STRCTLSZ 1024 1024 1024 1024 1024
STRMSGSZ 65535 65535 65535 65535 65535
acctresume 4 4 4 4 4
acctsuspend 2 2 2 2 2
aio_listio_max 256 256 256 256 256
aio_max_ops 2048 2048 2048 2048 2048
aio_physmem_pct 10 10 10 10 10
aio_prio_delta_max 20 20 20 20 20
allocate_fs_swapmap 0 0 0 0 0
alwaysdump 1 1 1 1 1
bcvmap_size_factor 2 2 n/a 2 n/a
bootspinlocks - - - - -
bufcache_hash_locks 128 128 128 128 128
bufpages 0 0 0 0 0
chanq_hash_locks 256 256 256 256 256
core_addshmem_read 0 0 0 0 0
core_addshmem_write 0 0 0 0 0
create_fastlinks 0 0 0 0 0
dbc_max_pct 50 50 10 10 50
dbc_min_pct 5 5 5 5 5
default_disk_ir 1 1 0 0 0
desfree - - - - -
disksort_seconds 0 0 0 0 0
dmp_rootdev_is_vol 0 0 n/a 0 n/a
dmp_swapdev_is_vol 0 0 n/a 0 n/a
dnlc_hash_locks 512 512 512 512 512
 
is that a statement or a question?

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
In the awk man page pay attention to the printf function.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
ha ha ha ha :eek:} I guess the question (from the title: how to print to get formatted columns) is to put this data into nice columns..

well, awk is your friend, asumming these data is in the file kernel.txt:
[tt}
awk '{ printf("%s\t%s\t%s\t%s\t%s\t%s\t",$1,$2,$3,$4,$5,$6) }' kernel.txt
[/tt]

or replace spaces with tab using [tt]sed[/tt]? (I am not so good with sed)


 
hmmm...
[tt]
awk '{ printf("%s\t\t%s\t%s\t%s\t%s\t%s\t[red]\n[/red]",$1,$2,$3,$4,$5,$6) }' kernel.txt
[/tt]
 
this is nice:
[tt]
awk '{ printf("%[red]-20s[/red]\t%s\t%s\t%s\t%s\t%s\t\n",$1,$2,$3,$4,$5,$6) }' kernel.txt
[/tt]
 
Or, if you have the [tt]column[/tt] program, just pipe the file to [tt]column[/tt].

e.g.
Code:
$ head -n2 /etc/passwd |column -t -s:
[COLOR=red]root  x  0  0  root  /root  /bin/bash
bin   x  1  1  bin   /bin   /sbin/nologin[/color]
Just give a space to the [tt]-s[/tt] option instead of a colon.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top