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.
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:
for f in input/*; do BN=$(basename "$f"); ffmpeg -i "$f" -vn "temp/$BN.flac"; sox "temp/$BN.flac" "temp/$BN-cleaned.flac" noisered profile 0.3; ffmpeg -i "$f" -vcodec copy -an "temp/$BN-na.mp4"; ffmpeg -i "temp/$BN-na.mp4" -i "temp/$BN-cleaned.flac" "output/$BN"; done
This was over the 255 character limit and I didn't feel like deliberately obfuscating it.
1. Create 'input', 'output' and 'temp' directories.
2. Place the files that you want to remove the hiss/static/general noise from in the input directory.
3. Generate a noise reduction profile with sox using 'sox an_input_file.mp4 -n trim x y noiseprof profile', where x and y indicates a range in seconds that only the sound you want to eliminate is present in.
4. Run the command.
calls grep on all non-binary files returned by find on its current working directory
This example code is intended to be used as a root permissions check in a script. It makes use of the $EUID (effective user ID) environment variable which is fully su- and sudo-safe.
set CDIR for it to work right..
Tar - Compress by excluding folders
get-ipsw device-name generation-string firmware-version
get-ipsw iPod 2,1 4.0
Different generation strings:
iPhone 3G: iPhone 1,2
iPhone 3GS: iPhone 2,1
iPod touch 2G: iPod 2,1
iPod touch 3G: iPod 3,1
This can be used with idevicerestore (I haven't tried it though).
Some shell newbies don't know this very handy file management related command so I decided to include it here.
You need to have the "file" package installed.
Saves opening another console terminal (eg. CTRL+ALT+F[n]) or opening another remote terminal.
Ctrl+Z pauses the current task and pushed it to the background, leaving you with a command prompt for those "Oh crap I forgot to change xyz before I ran that and it'll take forever if I Ctrl+C and start again..." situations. Typing 'fg' (shorthand for foreground, that's how I remember it) will resume the paused task.
Bash scrip to test if a server is up, you can use this before wget'ing a file to make sure a blank one isn't downloaded.
Every seconds do
I wanted to play a song from the shell and get the shell back, I also dont want to store the file if it is not needed.
edit, not sure if I need to mention it... killall vlc to stop it
compare to alternative :
- directly tests the -STOP of the process to continue or stop loop,
- background operator should be set (or not) at the call of the function
For extension i suggest a slowPID() based on kill like above and a slowCMD based on killall.
On my music directory, I create variable that contains all mp3s files, then I play them with mpg123. -C options enable terminal control key, s for stop, p for pause, f for forward to next song.
Remove all empty directories below the current directory. If directories become empty as the results of this, remove those too.
Get just the IP address for a given hostname. For best results, make this a function in your shell rc file so that it can be used for things like traceroute:
Titus:~$ traceroute `getip foo.com`
traceroute to 22.214.171.124 (126.96.36.199), 64 hops max, 52 byte packets
Have wc work on each file then add up the total with awk; get a 43% speed increase on RHEL over using "-exec cat|wc -l" and a 67% increase on my Ubuntu laptop (this is with 10MB of data in 767 files).
By default, slot 1 is used for OTP purposes and validates against the Yubikey servers. Running the command above will replace that. If you have a Yubikey 2 or above, you can change -1 to -2 and program the second slot with a strong static key.
take a list of IP:PORT and output IP:PORT:COUNTRY
Traffic details on the Ethernet interface.
When you press "cmd+n" in TextMate, you can have "HTML" language as default document format... You can also define other languages too. You need to know the UUID of your language bundle.