Quantcast
Channel: Commands tagged column sorted by votes
Browsing latest articles
Browse All 28 View Live
↧

Image may be NSFW.
Clik here to view.

Sum 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 Article


Image may be NSFW.
Clik here to view.

currently 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 Article


Image may be NSFW.
Clik here to view.

Sum 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 Article

Image may be NSFW.
Clik here to view.

Sum 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 Article

Image may be NSFW.
Clik here to view.

Print 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 Article


Image may be NSFW.
Clik here to view.

Print 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 Article

Image may be NSFW.
Clik here to view.

Using 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 Article

Image may be NSFW.
Clik here to view.

View 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


Image may be NSFW.
Clik here to view.

View 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 Article


Image may be NSFW.
Clik here to view.

Advanced 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 Article

Image may be NSFW.
Clik here to view.

STAT 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 Article

Image may be NSFW.
Clik here to view.

Show 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 Article

Image may be NSFW.
Clik here to view.

format 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 Article


Image may be NSFW.
Clik here to view.

format 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 Article

Image may be NSFW.
Clik here to view.

format 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 Article


Image may be NSFW.
Clik here to view.

Print 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 Article

Image may be NSFW.
Clik here to view.

Check 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 Article


Image may be NSFW.
Clik here to view.

Select 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 Article

Image may be NSFW.
Clik here to view.

Show 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

Image may be NSFW.
Clik here to view.

Print 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 Article

Image may be NSFW.
Clik here to view.

Show 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 Article


Image may be NSFW.
Clik here to view.

Extract 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 Article


Image may be NSFW.
Clik here to view.

drop 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 Article

Image may be NSFW.
Clik here to view.

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 Article

Image may be NSFW.
Clik here to view.

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 Article

Browsing latest articles
Browse All 28 View Live