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.
If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/
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:
This is a slightly modified version of http://www.commandlinefu.com/commands/view/4283/recursive-search-and-replace-old-with-new-string-inside-files (which did not work due to incorrect syntax) with the added option to sed inside only files named filename.ext
Your computer's name is raspberrypi and you want to rename it to pita1.
This command will change both the hostname and the name used for netwrk communications.
remove old index.html if you download it again and organiaz the java script tag on the file index.html
Put it in your ~/.bashrc
usage:
google word1 word2 word3...
google '"this search gets quoted"'
I found this command on a different site and thought you guy might enjoy it. Just change "YOURSEARCH" to what ever you want to search. Example, "Linux Commands"
Remove ( color / special / escape / ANSI ) codes, from text, with sed
Credit to the original folks who I've copied this command from.
The diff here is:
Theirs: [m|K]
Theirs is supposed to remove \E[NUMBERS;NUMBERS[m OR K]
This statement is incorrect in 2 ways.
1. The letters m and K are two of more than 20+ possible letters that can end these sequences.
2. Inside []'s , OR is already assumed, so they are also looking for sequences ending with | which is not correct.
This : [a-zA-Z]
This resolves the "OR" issue noted above, and takes care of all sequences, as they all end with a lower or upper cased letter.
This ensures 100% of any escape code 'mess' is removed.
In these command i use lynx to get the top trend topic of Mexico, if you replace Mexico with other country, you will get the #1 Trending topic
Replace "user/sbin/sshd" with the file you would like to check. If you are doing this due to intrusion, you obviously would want to check size, last modification date and md5 of the md5sum application itself. Also, note that "/var/lib/dpkg/info/*.md5sums" files might have been tampered with themselves. Neither to say, this is a useful command.
(Please see sample output for usage)
Use any script name (the read command gets it) and it will be encrypted with the extension .crypt, i.e.:
myscript --> myscript.crypt
You can execute myscript.crypt only if you know the password. If you die, your script dies with you.
If you modify the startup line, be careful with the offset calculation of the crypted block (the XX string).
Not difficult to make script editable (an offset-dd piped to a gpg -d piped to a vim - piped to a gpg -c directed to script.new ), but not enough space to do it on a one liner.
Sorry for the chmod on parentheses, I dont like "-" at the end.
Thanks flatcap for the subshell abbreviation to /dev/null
(Please see sample output for usage)
script.bash is your script, which will be crypted to script.secure
script.bash --> script.secure
You can execute script.secure only if you know the password. If you die, your script dies with you.
If you modify the startup line, be careful with the offset calculation of the crypted block (the XX string).
Not difficult to make script editable (an offset-dd piped to a gpg -d piped to a vim - piped to a gpg -c directed to script.new ), but not enough space to do it on a one liner.
Assuming a convention looking group file, this command will eject oldspiderman from the leagueofsuperfriends group and add newspiderman:
oldspiderman:x:551:
aquaman:x:552:
superman:x:553:
newspiderman:x:554:
leagueofsuperfriends:x:1000:superman,oldspiderman,superman,aquaman
Avoids the nested 'find' commands but doesn't seem to run any faster than syssyphus's solution.
1.- Enter into the playlist path.
2.- Run the command.
3.- Playlists created!
Replaces hexdump with the more succint xxd, and the sed was unnecessarily complex.
I look at xkcd in my news reader, but it displays the image's title attribute only for a few seconds which makes reading the longer ones more challenging. So I use this to display it in my console.
or
od /dev/urandom -w60 -An|sed 's/ ..../ /g'|head -n 30
(this one lacks digits 8 and 9)