commandlinefu.com is the place to record those command-line gems that you return to again and again.
You can sign-in using OpenID credentials, or register a traditional username and password.
Subscribe to the feed for:
# git commit -m"Jira #404 - `whatthecommit`"
first off, if you just want a random UUID, here's the actual command to use:
Your chances of finding a duplicate after running this nonstop for a year are about the same as being hit by a meteorite before finishing this sentence
The reason for the command I have is that it's more provably unique than the one that uuidgen creates. uuidgen creates a random one by default, or an unencrypted one based on time and network address if you give it the -t option.
Mine uses the mac address of the ethernet interface, the process id of the caller, and the system time down to nanosecond resolution, which is provably unique over all computers past, present, and future, subject to collisions in the cryptographic hash used, and the uniqueness of your mac address.
Warning: feel free to experiment, but be warned that the stdin of the hash is binary data at that point, which may mess up your terminal if you don't pipe it into something. If it does mess up though, just type
The output is only partial because runtime dependencies should count in also commands executed via system() and libraries loaded with dlopen(), but at least it gives an idea of what a package directly links to.
Note: this is meaningful *only* if you're using -Wl,--as-needed in your LDFLAGS, otherwise it'll bring you a bunch of false positives.
cat WAR_AND_PEACE_By_LeoTolstoi.txt | tr -cs "[:alnum:]" "\n"| tr "[:lower:]" "[:upper:]" | sort -S16M | uniq -c |sort -nr | cat -n | head -n 30
("sort -S1G" - Linux/GNU sort only) will also do the job but as some drawbacks (caused by space/time complexity of sorting) for bigger files...
This command will format your alias or function to a single line, trimming duplicate white space and newlines and inserting delimiter semi-colons, so it continues to work on a single line.
This will get the mac address of the eth0 and change lowercase to uppercase.
The sed command removed the colons.
Simple bash/ksh/sh command to rename all files from lower to upper case. If you want to do other stuff you can change the tr command to a sed or awk... and/or change mv to cp....
Generates a random 8-character password that can be typed using only the left hand on a QWERTY keyboard. Useful to avoid taking your hand off of the mouse, especially if your username is left-handed. Change the 8 to your length of choice, add or remove characters from the list based on your preferences or kezboard layout, etc.
add integers from the stdin and print out the result
usually, cat /tmp/file | echo $(($(tr '\n' '+')0))
with grep for em:name rather than name, you will get much better result.
1.) my profile ends with $USER not with .default
2.) only grep for the first occurrence because some extensions have the translated name also inside the install.rdf
I noticed some spammer posted an advertisement here for "not bad" encryption. Unfortunately, their software only runs under Microsoft Windows and fails to work from the commandline. My shell script improves upon those two aspects, with no loss in security, using the exact same "military-grade" encryption technology, which has the ultra-cool codename "ROT-13". For extra security, I recommend running ROT-13 twice.
This is N5 sorta like rot13 but with numbers only.
echo "$1" | xxd -p | tr '0-9' '5-90-6'
echo "$1" | tr '0-9' '5-90-6' | xxd -r -p
not the best, uses 4 pipes!
Get a list of all the unique hostnames from the apache configuration files. Handy to see what sites are running on a server. A slightly shorter version.
Get a list of all the unique hostnames from the apache configuration files. Handy to see what sites are running on a server.
shorter than alternative
The wherepath function will search all the directories in your PATH and print a unique list of locations in the order they are first found in the PATH. (PATH often has redundant entries.) It will automatically use your 'ls' alias if you have one or you can hardcode your favorite 'ls' options in the function to get a long listing or color output for example.
'whereis' only searches certain fixed locations.
'which -a' searches all the directories in your path but prints duplicates.
'locate' is great but isn't installed everywhere (and it's often too verbose).
Print a row of characters across the terminal. Uses tput to establish the current terminal width, and generates a line of characters just long enough to cross it. In the example '#' is used.
It's possible to use a repeating sequence by dividing the columns by the number of characters in the sequence like this:
seq -s'~-' 0 $(( $(tput cols) /2 )) | tr -d '[:digit:]'
seq -s'-~?' 0 $(( $(tput cols) /3 )) | tr -d '[:digit:]'
You will lose chararacters at the end if the length isn't cleanly divisible.