Commands by Robertof (1)

What's this?

commandlinefu.com 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

generate file list modified since last commit and export to tar file
################################################################################ # get all modified files since last commit and zip them to upload to live server ################################################################################ # delete previous tar output file rm mytarfile.tar -rf #rm c:/tarOutput/*.* -rf # get last commit id and store in variable declare RESULT=$(git log --format="%H" | head -n1) # generate file list and export to tar file git diff-tree -r --no-commit-id --name-only --diff-filter=ACMRT $RESULT | xargs tar -rf mytarfile.tar # extract tar files to specified location tar -xf mytarfile.tar -C c:/tarOutput

Do one ping to a URL, I use this in a MRTG gauge graph to monitor connectivity

Get your commandlinefu points (upvotes - downvotes)
This will calculate the your commandlinefu votes (upvotes - downvotes). Hopefully this will boost my commandlinefu points.

Pick a random line from a file

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" }

recursive search and replace old with new string, inside files
Using -Z with grep and -0 with xargs handles file names with spaces and special characters.

a function to find the fastest DNS server
http://public-dns.info gives a list of online dns servers. you need to change the country in url (br in this url) with your country code. this command need some time to ping all IP in list.

du and sort to find the biggest directories in defined filesystem
This command give a human readable result without messing up the sorting.

Convert string to uppercase

Find the package that installed a command


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.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

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: