currently 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 ArticleSum columns from CSV column $COL
$ perl -ne 'split /,/ ; $a+= $_[3]; END {print $a."\n";}' -f ./file.csv View this command to comment, vote or add to favourites View all commands by ioggstream by David Winterbottom (codeinthehole.com)
View Articlecurrently mounted filesystems in nice layout
$ column -t /proc/mounts since fuse mounts do not appear in /etc/mtab (fuse can't write there, dunno if it would if it could) this is propably a better way. View this command to comment, vote or add to...
View ArticleSum columns from CSV column $COL
$ awk -F ',' '{ x = x + $4 } END { print x }' test.csv View this command to comment, vote or add to favourites View all commands by coffeeaddict_nl by David Winterbottom (codeinthehole.com)
View ArticleSum columns from CSV column $COL
$ perl -F',' -ane '$a += $F[3]; END { print $a }' test.csv More of the same but with more elaborate perl-fu :-) View this command to comment, vote or add to favourites View all commands by...
View ArticlePrint text string vertically, one character per line.
$ echo "vertical text" | grep -o '.' Define a function vert () { echo $1 | grep -o '.'; } Use it to print some column headers paste <(vert several) <(vert parallel) <(vert vertical) <(vert...
View ArticlePrint text string vertically, one character per line.
$ echo "vertical text" | fold -1 View this command to comment, vote or add to favourites View all commands by zude by David Winterbottom (codeinthehole.com)
View ArticleUsing column to format a directory listing
$ (printf "PERMISSIONS LINKS OWNER GROUP SIZE MONTH DAY HH:MM PROG-NAME\n" \ ; ls -l | sed 1d) | column -t Using column to format a directory listing View this command to comment, vote or add to...
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 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 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 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 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 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 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 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 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 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 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 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 Article