Truncate long strings in columns and use custom header names
$ column -s: -t -n . -N USERNAME,PASS,UID,GID,NAME,HOMEDIR,SHELL -T NAME /etc/passwd|sed "1,2 i $(printf %80s|tr ' ' '=')" Using the --table-truncate ( -T ) option, you can specify the columns you will...
View Articlecurrently mounted filesystems in nice layout
$ mount | column -t Particularly useful if you're mounting different drives, using the following command will allow you to see all the filesystems currently mounted on your computer and their...
View Articledrop first column of output by piping to this
$ perl -pE's/(\S+\s*){0,1}//' An advantage is that this doesn't modify remained string at all. One can change {0,1} with {0,n} to drop several columns View this command to comment, vote or add to...
View ArticleA simple function to conveniently extract columns from an input stream
$ col() { awk '{print $('$(echo $* | sed -e s/-/NF-/g -e 's/ /),$(/g')')}'; } Something I do a lot is extract columns from some input where cut is not suitable because the columns are separated by not...
View ArticleUse wbinfo to output a table with basic user information from the default...
$ for DOMAIN in $(wbinfo -m); do WBSEP=$(wbinfo --separator); ADSERVER=$(wbinfo ... (Read description for full command))) ### for ADUSER in $(wbinfo -u --domain="$(wbinfo --own-domain)" | sort); do...
View ArticleExtract shortcuts and hostnames from .ssh/config
$ awk '$1=="Host"{$1="";H=substr($0,2)};$1=="HostName"{print H,"$",$2}' ~/.ssh/config | column -s '$' -t Spits out table that shows your Host->HostName aliases in ~/.ssh/config View this command to...
View ArticleShow complete URL in netstat output
$ netstat -pnut -W | column -t -s $'\t' This takes all of the tab spaces, and uses column to put them into the appropriately sized table. View this command to comment, vote or add to favourites View...
View ArticlePrint ASCII Character Chart
$ 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 Prints out an ascii chart using builtin bash! Then formats using cat -t and column. The best...
View ArticleShow complete URL in netstat output
$ netstat -tup -W | column -t 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...
View ArticleSelect columns in a file
$ cut -d: -f 1 names.txt Display the 1st field (employee name) from a colon delimited file View this command to comment, vote or add to favourites View all commands by ankush108 by David Winterbottom...
View ArticleCheck your unread Gmail from the command line
$ 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...
View ArticlePrint all lines from a file that has the same N th and M th column
$ awk '$3==$4' /etc/passwd View this command to comment, vote or add to favourites View all commands by totti by David Winterbottom (codeinthehole.com)
View Articleformat txt as table not joining empty columns adding header with column numbers
$ 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 version now adds a header with...
View Articleformat txt as table not joining empty columns
$ column -tns: /etc/passwd -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'...
View Articleformat txt as table
$ cat /etc/passwd | column -nts: View this command to comment, vote or add to favourites View all commands by kev by David Winterbottom (codeinthehole.com)
View ArticleShow numerical values for each of the 256 colors in bash
$ for i in {0..255}; do echo -e "\e[38;05;${i}m${i}"; done | column -c 80 -s ' '; echo -e "\e[m" I like the other three versions but one uses nested loops and another prints every color on a separate...
View ArticleSTAT Function showing ALL info, stat options, and descriptions
$ statt(){ C=c;stat --h|sed '/Th/,/NO/!d;/%/!d'|while read l;do p=${l/% */};[ $p == %Z ]&&C=fc&&echo ^FS:^;echo "`stat -$C $p \"$1\"` ^$p^${l#%* }";done|column -ts^; } This shows every...
View ArticleAdvanced LS Output using Find for Formatted/Sortable File Stat info
$ find $PWD -maxdepth 1 -printf '%.5m %10M %#9u:%-9g %#5U:%-5G [%AD | %TD | %CD] [%Y] %p\n' I love this function because it tells me everything I want to know about files, more than stat, more than ls....
View ArticleView advanced Sort options, Quick Reference Help Alias
$ alias sorth='sort --help|sed -n "/^ *-[^-]/s/^ *\(-[^ ]* -[^ ]*\) *\(.*\)/\1:\2/p"|column -ts":"' Once you get into advanced/optimized scripts, functions, or cli usage, you will use the sort command...
View ArticleView all date formats, Quick Reference Help Alias
$ alias dateh='date --help|sed -n "/^ *%%/,/^ *%Z/p"|while read l;do F=${l/% */}; date +%$F:"|'"'"'${F//%n/ }'"'"'|${l#* }";done|sed "s/\ *|\ */|/g" |column -s "|" -t' If you have used bash for any...
View Article