Commands by eakinc (2)

  • Requires psc, sed, sc, and cat. Working with csv spreadsheets with formulas in them to evaluate the formulas using sc. View the formulas in a numbered and lettered formated in command line. function sheet () { cat "$1" | sed '1s/^/a,b,c,d,e,f,g,h,j,k,l,m,n,o,p\n/' | column -s , -tn | nl -v 0 ; }

    cat FILE.csv |sed -e '1i,,,,,' |sed -e 's/=sum/@sum/g' -e 's/=SUM/@SUM/g' |psc -k -d, |sed -e 's/\"@SUM(/@SUM(/' -e 's/)"/)/' -e '/@SUM/ { s/rightstring/let/; }' -e '/= "=/s/rightstring/let/' -e '/= "=/s/"//g' -e 's/= =/= /g' |sc
    eakinc · 2015-07-13 04:11:31 0
  • In addition one can evaluate the formulas in the venerable spreadsheet command sc, with an additional command. function csvev () { cat $1 | sed -e '1i,,,,,,,' |sed -e 's/=sum/@sum/g' -e 's/=SUM/@SUM/g' | psc -k -d, | sed -e 's/\"@SUM(/@SUM(/' -e 's/)"/)/' | sed '/@SUM/ { s/rightstring/let/; }' | sed -e '/= "=/s/rightstring/let/' -e '/= "=/s/"//g' | sed 's/= =/= /g' | sc ; } I will post this command separately as well. Show Sample Output

    function sheet () { cat "$1" | sed '1s/^/a,b,c,d,e,f,g,h,j,k,l,m,n,o,p\n/' | column -s , -tn | nl -v 0 ; }
    eakinc · 2015-07-13 03:14:35 0

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Check These Out

rgrep: recursive grep without .svn
Only excludes .svn from filenames.

Find the package that installed a command

Bingo-like raffle
Random choose numbers from 1 to 100 with 5 seconds interval without duplicates.

reverse order of file

For finding out if something is listening on a port and if so what the daemon is.

list block devices
Shows all block devices in a tree with descruptions of what they are.

List subfolders from largest to smallest with sizes in human readable form

Watch postgresql calls from your application on localhost
It's certainly not nicely formatted SQL, but you can see the SQL in there...

Convert seconds to [DD:][HH:]MM:SS
Converts any number of seconds into days, hours, minutes and seconds. sec2dhms() { declare -i SS="$1" D=$(( SS / 86400 )) H=$(( SS % 86400 / 3600 )) M=$(( SS % 3600 / 60 )) S=$(( SS % 60 )) [ "$D" -gt 0 ] && echo -n "${D}:" [ "$H" -gt 0 ] && printf "%02g:" "$H" printf "%02g:%02g\n" "$M" "$S" }

Chmod all directories (excluding files)
+ at the end means that many filenames will be passed to every chmod call, thus making it faster. And find own {} makes sure that it will work with spaces and other characters in filenames.

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: