Used in OS X. tr "\n" ";" may be replaced by echo ";" with linux versions of date. I reused ping -q -c 1 www.google.com|tail -1|cut -d/ -f5 Show Sample Output
My first command :) I made this command to log public addresses of a virtual interface who connects random VPN servers around the world. Show Sample Output
Useful if localhost is a small machine running BusyBox, which uses a slightly unusual format to set the date. Remotehost can be pretty much any Linux machine, including one running BusyBox. Uses UTC for portability.
The easiest way to convert epoch date to human readable format. Show Sample Output
Downloads a CRL file, determines the expiration time, and checks when it will expire Show Sample Output
Calculate Sysadmin day of any given year using 2 `date`. Code based on http://stackoverflow.com/a/5656859/196133 Show Sample Output
This function will find the modification time in unix_time of the given file, then calculate the number of minutes from now to then and then find all files modified in that range. Show Sample Output
this command can be added to crontab so as to execute a nightly backup of directories and store only the 10 last backup files.
Take screen shot using Tizen SDK cd ~ # go to you home directory fn=$(date "+ screen-%H-%M-%S") # create variable for file name in bash sdb shell xwd -root -out /tmp/"$fn".xwd # open shell and run command to save screenshot sdb pull /tmp/"$fn".xwd ~/ # copy created file into your home directory convert "$fn".xwd "$fn".png # converting xwd to png in your home
usage = crontest "/path/to/bin" This version of this function will echo back the entire command so it can be copied/pasted to crontab. Should be able to be automagically appended to crontab with a bit more work. Tested on bash and zsh on linux,freebsd,aix Show Sample Output
s/espeak/say/ on a mac
I have this in my .bash_aliases and call it before running apt-get install or apt-get upgrade Example: alias apt-install='apt-update; apt-get install' alias apt-upgrade='apt-update; apt-get upgrade' function apt-update () { if [[ $(expr $(date +%s) - $(stat -c %X /var/lib/apt/periodic/update-success-stamp)) -gt 86400 ]]; then sudo apt-get update else echo apt is up to date fi }
For OS X/bsd; probably messy
This works out of the box in Mac Os X Show Sample Output
Creates a full backup of router's /etc (and any other files or directories specified in /etc/sysupgrade.conf) that gets stored into the computer as a tarball named with full date and time (YYYY-MM-DD-HH:MM).
minimal oneliner to keep track of time Show Sample Output
IMPORTANT: You need Windows PowerShell to run this command - in your Windows Command Prompt, type
powershell
Create a log file of your Motorola Surfboard SB6141 downstream signal strengths.
Uses the built-in curl to request signal strength data from your SB6141 cable modem.
HTML page 192.168.100.1/cmSignalData.htm has the signal strength numbers for the 8 downstreams.
Some HTML/DOM processing parses out the 8 values from the above page.
The eight extracted signal strengths are then logged to a file.
A small while-loop watches the clock & repeats the process every 10 seconds.
Show Sample Output
IMPORTANT: You need Windows PowerShell to run this command - in your Windows Command Prompt, type
powershell
Uses sajb to start a PowerShell background job that pings an IP host every 10 seconds.
Any changes in the host's Up/Down state is time-stamped and logged to a file.
Date/time stamps are logged in two formats: Unix and human-readable.
A while(1) loop repeats the test every 10 seconds by using the sleep command.
See the Sample Output for more detail.
I use this command to log Up/Down events of my Motorola SB6141 cable modem (192.168.100.1).
To end the logging, close the PowerShell window or use the "exit" command.
Show Sample Output
This will return a nice finish date and time when you're rebuilding a software raid array.
echo 'Current hour' hour=$(date +%H) if [ $hour -gt 9 -a $hour -lt 23 ]; then echo -n '*'; else echo -n '#'; fi; echo ' '$hour; echo 'Test around the clock:' for hour in {0..23} {0..23}; do if [ $hour -gt 9 -a $hour -lt 23 ]; then echo -n '*'; else echo -n '#'; fi; echo ' '$hour; done echo 'If you need to depend on UTC, just add `-u` flag to `date` command' Show Sample Output
A way for tracking times in bash Show Sample Output
Just add a format to chronometer in bash Show Sample Output
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.
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
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: