
Terminal - Commands using column - 42 results
for y in {1..10}; do for x in {1..10}; do echo -n "| $x*$y=$((y*x)) "; done; echo; done|column -t
This is sample output - yours may be different.
| 1*1=1 | 2*1=2 | 3*1=3 | 4*1=4 | 5*1=5 | 6*1=6 | 7*1=7 | 8*1=8 | 9*1=9 | 10*1=10
| 1*2=2 | 2*2=4 | 3*2=6 | 4*2=8 | 5*2=10 | 6*2=12 | 7*2=14 | 8*2=16 | 9*2=18 | 10*2=20
| 1*3=3 | 2*3=6 | 3*3=9 | 4*3=12 | 5*3=15 | 6*3=18 | 7*3=21 | 8*3=24 | 9*3=27 | 10*3=30
| 1*4=4 | 2*4=8 | 3*4=12 | 4*4=16 | 5*4=20 | 6*4=24 | 7*4=28 | 8*4=32 | 9*4=36 | 10*4=40
| 1*5=5 | 2*5=10 | 3*5=15 | 4*5=20 | 5*5=25 | 6*5=30 | 7*5=35 | 8*5=40 | 9*5=45 | 10*5=50
| 1*6=6 | 2*6=12 | 3*6=18 | 4*6=24 | 5*6=30 | 6*6=36 | 7*6=42 | 8*6=48 | 9*6=54 | 10*6=60
| 1*7=7 | 2*7=14 | 3*7=21 | 4*7=28 | 5*7=35 | 6*7=42 | 7*7=49 | 8*7=56 | 9*7=63 | 10*7=70
| 1*8=8 | 2*8=16 | 3*8=24 | 4*8=32 | 5*8=40 | 6*8=48 | 7*8=56 | 8*8=64 | 9*8=72 | 10*8=80
| 1*9=9 | 2*9=18 | 3*9=27 | 4*9=36 | 5*9=45 | 6*9=54 | 7*9=63 | 8*9=72 | 9*9=81 | 10*9=90
| 1*10=10 | 2*10=20 | 3*10=30 | 4*10=40 | 5*10=50 | 6*10=60 | 7*10=70 | 8*10=80 | 9*10=90 | 10*10=100
The multiplication table for math study
column -ts , /etc/openvpn/openvpn-status.log
This is sample output - yours may be different.
OpenVPN CLIENT LIST
Updated Tue May 17 12:17:42 2016
Common Name Real Address Bytes Received Bytes Sent Connected Since
router 25.123.12.14:2053 106406 119750 Tue May 17 07:26:02 2016
laptop 25.123.12.15:58976 21651 23552 Tue May 17 11:15:58 2016
desktop-debian 25.123.12.16:60921 3128193 3283546 Wed May 11 13:07:03 2016
raspberry1 25.123.12.14:48731 106919 113373 Tue May 17 07:26:34 2016
desktop-centos 25.123.12.17:56043 123061 156395 Tue May 17 07:18:14 2016
raspberry2 25.123.12.10:51085 4108 3924 Tue May 17 12:15:40 2016
ROUTING TABLE
Virtual Address Common Name Real Address Last Ref
10.254.253.38 raspberry1 25.123.12.14:48731 Tue May 17 07:26:41 2016
10.254.253.54 raspberry2 25.123.12.10:51085 Tue May 17 12:16:18 2016
10.254.253.22 router 25.123.12.14:2053 Tue May 17 07:26:43 2016
10.254.253.10 laptop 25.123.12.15:58976 Tue May 17 11:15:59 2016
10.254.253.50 desktop-debian 25.123.12.16:60921 Wed May 11 13:07:27 2016
10.254.253.70 desktop-centos 25.123.12.17:56043 Tue May 17 12:12:32 2016
GLOBAL STATS
Max bcast/mcast queue length 6
END
Formats nicely the Openvpn log file.
This is sample output - yours may be different.
col_look(){ column -nts$'\t' "$1" | less -SN#2 }
This is sample output - yours may be different.
Opens up a tab separated file in less with columns printed prettily
mosth() { history | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n10; }
This is sample output - yours may be different.
$ mosth
1 86 8.6% rpm
2 64 6.4% yum
3 47 4.7% echo
4 36 3.6% ip
5 36 3.6% cat
6 35 3.5% ls
7 32 3.2% cd
8 27 2.7% systemctl
9 27 2.7% journalctl
10 25 2.5% nano
I copied this (let's be honest) somewhere on internet and I just made it as a function ready to be used as alias. It shows the 10 most used commands from history. This seems to be just another "most used commands from history", but hey.. this is a function!!! :D
sc query state= all | awk '/SERVICE_NAME/{printf"%s:",$2;getline;gsub(/DISP.*:\ /,"");printf"%s\n",$0}' | column -ts\:
This is sample output - yours may be different.
gupdatem Google Update Service (gupdatem)
hidserv Human Interface Device Access
hkmsvc Health Key and Certificate Management
IAStorDataMgrSvc Intel(R) Rapid Storage Technology
idsvc Windows CardSpace
IEEtwCollectorService Internet Explorer ETW Collector Service
IKEEXT IKE and AuthIP IPsec Keying Modules
ImDskSvc ImDisk Virtual Disk Driver Helper
IPBusEnum PnP-X IP Bus Enumerator
iphlpsvc IP Helper
Outputs Windows Services service name and display name using "sc query", pipes the output to "awk" for processing, then "column" for formatting.
List All Services:
sc query state= all | awk '/SERVICE_NAME/{printf"%s:",$2;getline;gsub(/DISP.*:\ /,"");printf"%s\n",$0}' | column -ts\:
List Started Services:
sc query | awk '/SERVICE_NAME/{printf"%s:",$2;getline;gsub(/DISP.*:\ /,"");printf"%s\n",$0}' | column -ts\:
List Stopped Services:
sc query state= inactive| awk '/SERVICE_NAME/{printf"%s:",$2;getline;gsub(/DISP.*:\ /,"");printf"%s\n",$0}' | column -ts\:
ps axo pcpu,args | awk '/[p]hp.*pool/ { sums[$4] += $1 } END { for (pool in sums) { print sums[pool], pool } }' | sort -rn | column -t
This is sample output - yours may be different.
981.8 abc_live
520.9 def_live
0.1 abc_staging
0 default
0 def_staging
docker ps | sed -e 's/ /\+/g' -e 's/CONTAINER ID/CONTAINER_ID/' | tr -s '+' '\t' | q -t 'select c1,substr(c7, 0, 40),c2,c6 from -' | column -t
This is sample output - yours may be different.
CONTAINER_ID NAMES IMAGE PORTS
ad9d74b9a1bd akaivola/ndb:datanode ndb_datanode2_1
be9c3a7c2c4b akaivola/ndb:datanode ndb_datanode1_1
983c6eada93c ndb_sqlnode1_1 akaivola/ndb:sql 0.0.0.0:49233->3306/tcp, 0.0.0.0:49234->8500/tcp
16de1f8a672c ndb_sqlnode2_1 akaivola/ndb:sql 0.0.0.0:49231->3306/tcp, 0.0.0.0:49232->8500/tcp
7c6b790739f6 ndb_datanode1_1/management_1,ndb_datano akaivola/ndb:management 0.0.0.0:49230->1186/tcp
d1136b0ba95c ndb_datanode1_1/etcd_1,ndb_datanode1_1/ coreos/etcd:latest 7001/tcp, 0.0.0.0:49229->4001/tcp
88349c3c1f9a akaivola/databaseinitializer:latest databaseinitializer
f1bd06c6950c dnsmasq pmenglund/dnsmasq:latest 172.17.42.1:53->53/udp, 53/tcp
53fd22d0b727 consul 192.168.50.50:5000/akaivola/consul:latest 0.0.0.0:8301->8301/tcp, 0.0.0.0:8302->8302/tcp, 0.0.0.0:8400->8400/tcp, 0.0.0.0:8500->8500/tcp, 0.0.0.0:8600->8600/udp
fcc385af7c63 jenkinsmysql akaivola/jenkins-mysql:latest 0.0.0.0:3306->3306/tcp
When you run a lot of containers the built in docker ps output becomes unreadable. This command formats the output to be easier on the eyes.
Requires q (https://github.com/harelba/q) text as data.
awk '$1=="Host"{$1="";H=substr($0,2)};$1=="HostName"{print H,"$",$2}' ~/.ssh/config | column -s '$' -t
This is sample output - yours may be different.
Spits out table that shows your Host->HostName aliases in ~/.ssh/config
netstat -pnut -W | column -t -s $'\t'
This is sample output - yours may be different.
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 192.168.178.139:59711 xxx.xxx.xxx.xx:7000 ESTABLISHED 7211/xchat
tcp 0 0 192.168.178.139:46307 xxx.xxx.xxx.xxx:2204 ESTABLISHED 37550/ssh
tcp 0 0 192.168.178.139:39466 xxx.xxx.xxx.xxx:22 ESTABLISHED 36789/ssh
tcp 0 0 192.168.178.139:54130 xxx.xx.xxx.x:22 ESTABLISHED 7405/ssh
tcp 0 0 192.168.178.139:52571 xxx.xx.x.xx:22 ESTABLISHED 32981/ssh
tcp 0 0 192.168.178.139:37883 xxx.xxx.xxx.xxx:22 ESTABLISHED 9419/ssh
This takes all of the tab spaces, and uses column to put them into the appropriately sized table.
for i in {1..256};do p=" $i";echo -e "${p: -3} \\0$(($i/64*100+$i%64/8*10+$i%8))";done|cat -t|column -c120
This is sample output - yours may be different.
1 ^A 38 & 75 K 112 p 149 M-^U 186 M-: 223 M-_
2 ^B 39 ' 76 L 113 q 150 M-^V 187 M-; 224 M-`
3 ^C 40 ( 77 M 114 r 151 M-^W 188 M-< 225 M-a
4 ^D 41 ) 78 N 115 s 152 M-^X 189 M-= 226 M-b
5 ^E 42 * 79 O 116 t 153 M-^Y 190 M-> 227 M-c
6 ^F 43 + 80 P 117 u 154 M-^Z 191 M-? 228 M-d
7 ^G 44 , 81 Q 118 v 155 M-^[ 192 [email protected] 229 M-e
8 ^H 45 - 82 R 119 w 156 M-^\ 193 M-A 230 M-f
9 ^I 46 . 83 S 120 x 157 M-^] 194 M-B 231 M-g
10 47 / 84 T 121 y 158 M-^^ 195 M-C 232 M-h
11 ^K 48 0 85 U 122 z 159 M-^_ 196 M-D 233 M-i
12 ^L 49 1 86 V 123 { 160 M- 197 M-E 234 M-j
netstat -tup -W | column -t
This is sample output - yours may be different.
$ netstat -tup
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 me:41486 XXX.XXX.XXX.XXX-sta:http ESTABLISHED 1669/chrome
$ netstat -tup -W | column -t
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 me:41486 XXX.XXX.XXX.XXX-static.reverse.softlayer.com:http ESTABLISHED 1669/chrome
The -W switch of netstat makes it print complete URL of the connections, which otherwise by default
is truncated to fit its default column size.
Now to compensate for irregular column sizes, pipe the output to column (-t switch of column prints in tabular form). The only downside to this part is that the very first row, the header, goes pear shape.
bind -P | grep -v "is not" | sed -e 's/can be found on/:/' | column -s: -t
This is sample output - yours may be different.
abort "\C-g", "\C-x\C-g", "\e\C-g".
accept-line "\C-j", "\C-m".
backward-char "\C-b", "\eOD", "\e[D".
backward-delete-char "\C-h", "\C-?".
...
Shows all available keyboard bindings in bash. Pretty printing.
for i in {0..255}; do echo -e "\e[38;05;${i}m\\\e[38;05;${i}m"; done | column -c 80 -s ' '; echo -e "\e[m"
This is sample output - yours may be different.
\e[38;05;1m
\e[38;05;2m
\e[38;05;3m
Prints an easy-to-copy color code for each color.
history | awk '{CMD[$4]++;count++;} END { for (a in CMD )print CMD[a] " " CMD[a]/count*100 "% " a }' | sort -nr | nl | column -t | head -n 10
This is sample output - yours may be different.
1 1928 19.28% ll
2 1341 13.41% cd
3 1127 11.27% ls
4 576 5.76% cat
5 364 3.64% vim
6 243 2.43% ssh
7 211 2.11% vi
8 196 1.96% pt-table-sync
9 189 1.89% rm
10 186 1.86% mysql
perhaps you should use CMD[$2] instead of CMD[$4]
for code in $(seq -w 0 255); do for attr in 0 1; do printf "%s-%03s %bTest%b\n" "${attr}" "${code}" "\e[${attr};38;05;${code}m" "\e[m"; done; done | column -c $((COLUMNS*2))
This is sample output - yours may be different.
Shows the ?rendering? for each of the 256 colours in both the bold and normal variant. Using seq is helpful to get even lines, passing $((COLUMNS*2)) to column sort-of-handles the nonprintable characters.
sed 's/#.*//' /etc/fstab | column -t
This is sample output - yours may be different.
fdisk -l /dev/sda | grep -E sda[0-9]+ | sed s/*// | awk '{printf ("%s %f ",$1,$2/512); if($2%512){ print "BAD" }else {print "Good"} }' | column -t
This is sample output - yours may be different.
/dev/sda1 4.000000 Good
/dev/sda2 404.000000 Good
/dev/sda3 160404.000000 Good
/dev/sda4 1520004.000000 Good
/dev/sda5 1520008.000000 Good
/dev/sda6 1521988.000000 Good
/dev/sda7 1643216.000000 Good
/dev/sda8 1659220.000000 Good
/dev/sda9 1787472.000000 Good
To get most of you HDD/SSD driver you need to make sure you partition are aligned, if not the speed penalty can be up to 50% slower!
this simple one liner will check to see if each partition start sector is divided by 512
you need to change sda with your driver
if you find the one of your partitions is not aligned use gparted to move the start sector of the partition to be divided of 512
sudo ps aux --sort:rss | awk '{print $2"\t"$11": "$6/1024" MB"}' | column -t | less
This is sample output - yours may be different.
2406 guake: 31.0586 MB
2385 unity-2d-panel: 32.3125 MB
2411 /usr/lib/vmware-tools/sbin64/vmtoolsd: 35.8125 MB
11320 /usr/lib/chromium-browser/chromium-browser: 37.0352 MB
11260 /usr/lib/chromium-browser/chromium-browser: 37.625 MB
2386 unity-2d-launcher: 45.4844 MB
2839 /usr/bin/unity-2d-places: 52.1562 MB
11133 /usr/lib/chromium-browser/chromium-browser: 100.266 MB
1013 /usr/bin/X: 134.688 MB
11161 /usr/lib/chromium-browser/chromium-browser: 163.75 MB
curl -u username --silent "https://mail.google.com/mail/feed/atom" | awk 'BEGIN{FS="\n";RS="(</entry>\n)?<entry>"}NR!=1{print "\033[1;31m"$9"\033[0;32m ("$10")\033[0m:\t\033[1;33m"$2"\033[0m"}' | sed -e 's,<[^>]*>,,g' | column -t -s $'\t'
This is sample output - yours may be different.
Just an alternative with more advanced formating for readability purpose. It now uses colors (too much for me but it's a kind of proof-of-concept), and adjust columns.
cat file.csv | perl -pe 'if($. == 1) {@h = split(/;/); $i = 1 ; map { $_ = $i; $i++ } @h; print join(" ;", @h) , "\n"} ; s/(^|;);/$1 ;/g' | column -ts\; | less -S
This is sample output - yours may be different.
cat file.csv
column_a;column_b;column_c
a;b;c
;b;c
a;b;
cat file.csv | perl -pe 'if($. == 1) {@h = split(/;/); $i = 1 ; map { $_ = $i; $i++ } @h; print join(" ;", @h) , "\n"} ; s/(^|;);/$1 ;/g' | column -ts\;
1 2 3
column_a column_b column_c
a b c
b c
a b
This version now adds a header with consecutive numbering.
This is sample output - yours may be different.
-n switch keeps empty columns
If your distribution does not ship with a recent column version that supports -n you can use this alternative:
perl -pe 's/(^|;);/$1 ;/g' file.csv | column -ts\; | less -S
Change the delimiter to your liking.
cat /etc/passwd | column -nts:
This is sample output - yours may be different.
root x 0 0 root /root /bin/bash
bin x 1 1 bin /bin /sbin/nologin
daemon x 2 2 daemon /sbin /sbin/nologin
pacman -Qi $(pacman -Qq)|grep 'Name\|Size'| cut -d: -f2 | paste - - | column -t | sort -nk2
This is sample output - yours may be different.
This is sample output - yours may be different.