Commands using wc (172)

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

Merge PDFs with Ghostscript wrapped in a function
This is an expansion on a previous entry, which I've wrapped in a function and placed in my profile. The "$@" is a positional parameter, much like "$*", but the parameters are passed on intact, without interpretation or expansion; so you can simply call the function like this: mergepdf * This will output a merged PDF of all PDFs in the current directory. Alternatively, you can simply list them like so: mergepdf 00.pdf 01.pdf 02.pdf ... N.B. Passing a wildcard will merge all PDFs in the current directory in name order, e.g. 00.pdf 01.pdf aa.pdf ab.pdf

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

rename files according to file with colums of corresponding names
Maybe simpler, but again, don't know how it will work with space in filename.

Command to logout all the users in one command
Only to logout all users except root

Convert Squid unixtime logs in human-readable ones
On-the-fly conversion of Unix Time to human-readable in Squid's access.log

Makefile argument passing
This would allow reference of $(VAR) (if defined) with the value 'foobar' within the Makefile.

Get AWS temporary credentials ready to export based on a MFA virtual appliance
You might want to secure your AWS operations requiring to use a MFA token. But then to use API or tools, you need to pass credentials generated with a MFA token. This commands asks you for the MFA code and retrieves these credentials using AWS Cli. To print the exports, you can use: `awk '{ print "export AWS_ACCESS_KEY_ID=\"" $1 "\"\n" "export AWS_SECRET_ACCESS_KEY=\"" $2 "\"\n" "export AWS_SESSION_TOKEN=\"" $3 "\"" }'` You must adapt the command line to include: * $MFA_IDis ARN of the virtual MFA or serial number of the physical one * TTL for the credentials

Create a mirror of a local folder, on a remote server
Create a exact mirror of the local folder "/root/files", on remote server 'remote_server' using SSH command (listening on port 22) (all files & folders on destination server/folder will be deleted)

Run a long job and notify me when it's finished
You will need libnotify-bin for this to work: $ sudo aptitude install libnotify-bin

function to edit your history file
eh stands for Edit History . Frequently, I'll mistype a command, and then step back through my history and correct the command. As a result, both the correct and incorrect commands are in my history file. I wanted a simple way to remove the incorrect command so I don't run it by mistake. . When running this function, first the ~/bash_history file is updated, then you edit the file in vi, and then the saved history file is loaded back into memory for current usage. . while in vi, remember that `Shift-G` sends you to the bottom of the file, and `dd` removes a line. . this command is different than bash built-in `fc` because it does not run the command after editing.

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: