commandlinefu.com is the place to record those command-line gems that you return to again and again.
Delete that bloated snippets file you've been using and share your personal repository with the world. 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.
You can sign-in using OpenID credentials, or register a traditional username and password.
First-time OpenID users will be automatically assigned a username which can be changed after signing in.
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:
Based on http://stackoverflow.com/questions/13127352/checking-alternative-names-for-a-san-ssl-cert
Replace "facebook.com" with the desired hostname.
Command will succeed n% of the time.
ran 75 will cause command to succeed 75% of the time.
No argument will cause it to succeed 50% of the time.
Scope should have the Rigol Ultravision Technology otherwise it won't accept the command. ImageMagic is required. Scope sends a 1.1M BMP file and converted to PNG it's only 18-20K
So, I'm using a CentOS VM in VirtualBox, and created four new disks in the SCSI controller.
The VM created the folders:
/dev/sda
/dev/sdb
/dev/sdc
/dev/sdd
Using a 'for loop' all disks are partitioned for LVM.
It's useful when you cannot access your env (systemd) or the process DISPLAY variable is not set. Perhaps also when you have a multi-head/user configuration.
Many times I give the same commands in loop to find informations about a file. I use this as an alias to summarize that informations in a single command. Now with variables! :D
perl version of "Wait for file to stop changing"
When "FileName" has not been changed for last 10 seconds, then print "DONE"
"10" in "(stat)[10]" means ctime.
One have other options like atime, mtime and others. http://perldoc.perl.org/functions/stat.html
This loop will finish if a file hasn't changed in the last 10 seconds.
.
It checks the file's modification timestamp against the clock.
If 10 seconds have elapsed without any change to the file, then the loop ends.
.
This script will give a false positive if there's a 10 second delay between updates,
e.g. due to network congestion
.
How does it work?
'date +%s' gives the current time in seconds
'stat -c %Y' gives the file's last modification time in seconds
'$(( ))' is bash's way of doing maths
'[ X -lt 10 ]' tests the result is Less Than 10
otherwise sleep for 1 second and repeat
.
Note: Clever as this script is, inotify is smarter.
alternatively, run the spinner for 5 seconds:
timeout 5 bash -c 'spinner=( Ooooo oOooo ooOoo oooOo ooooO oooOo ooOoo oOooo); while true; do for i in ${spinner[@]}; do for j in seq 0 ${#i}; do echo -en "\b\b"; done; echo -ne "${i}"; sleep 0.2; done; done'
(here is character '+' repeated 80 times)
Sometimes needed to enhance the title of the script.
Working with lists of IP addresses it is sometimes useful to summarize a count of how many times an IP address appears in the file.
This example, summarizeIP, uses another function "verifyIP" previously defined in commandlinefu.com to ensure only valid IP addresses get counted. The summary list is presented in count order starting with highest count.
This command will create a popup reminder window to assist in remembering tasks
http://i.imgur.com/2n7viiA.png is how it looks when created
This method does not transfer the contents of the entire file, instead it computes a md5 sum of the file on each end so that large files can be compared without transferring them across the net.
I used this fragment with Imagemagick convert so that I can place long text strings in pictures. The "\n" gets converted to a true newline in the image.
So this fragment uses fold command to wrap the line and then sed to convert newlines (and any trailing spaces on the line) to the text "\n"
After you run this script, you can check status for broken symlink with this command:
find -L . -type l
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