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:
Tail all logs that are opened by all java processes. This is helpful when you are on a new environment and you do not know where the logs are located. Instead of java you can put any process name. This command does work only for Linux.
The list of all log files opened by java process:
sudo ls -l $(eval echo "/proc/{$(echo $(pgrep java)|sed 's/ /,/')}/fd/")|grep log|sed 's/[^/]* //g'
Negative shell globs already come with bash. Make sure to turn on extended pattern matching with 'shopt -e extglob'.
I've been looking for a way to do this for a while, get a not pattern for shell globs. This works, I'm using to grab logs from a remote server via scp.
This version eliminates the grep before the awk, which is always good. It works for GNU core utils and ensures that the date output of ls matches the format in the pattern match, regardless of locale, etc.
On BSD-based systems, you can easily eliminate both the grep and the awk:
find . -maxdepth 1 -Btime -$(date +%kh%lm) -type f
This takes quite a while on my system. You may want to test it out with /bin first, or background it and keep working.
If you want to get rid of the "No manual entry for [whatever]" and just have the [whatever], use the following sed command after this one finishes.
sed -n 's/^No manual entry for \(.*\)/\1/p' nomanlist.txt
Really, you deserve whatever happens if you have a whitespace character in a file name, but this has a small safety net. The truly paranoid will use '-i'.
requires "youtube-dl" -- sure you can do this with wget and some more obscurity but why waste your time when this great tool is available?
the guts consist of mplayer converting a video to a gif -- study this command and read the man page for more information
mplayer video.flv -ss 00:23 -endpos 6 -vo gif89a:fps=5:output=output.gif -vf scale=400:300 -nosound
generates a 6 second gif starting at 23 seconds of play time at 5 fps and a scale of 400x300
start time (-ss)/end time (-endpos) formats: 00:00:00.000
end time should be relative to start time, not absolute. i.e. -endpos 5 == seconds after 0:42 = 0:47 end point
play with fps and scale for lower gif sizes
the subshell is a solution for the -b flag on youtube-dl which downloads the best quality video, sometimes, which can be various video formats $(ls ${url##*=}*| tail -n1)
This will list all symlinks that are directories under the current directory. This will help you distinguish them from regular files.
You may also use the $(which foo) variant instead of backticks. I personnaly have an alias ll='ls -l'.
You need to have fortune and cowsay installed. It uses a subshell to list cow files in you cow directory (this folder is default for debian based systems, others might use another folder).
you can add it to your .bashrc file to have it great you with something interesting every time you start a new session.
This function does a batch edition of all OOO3 Writer files in current directory. It uses sed to search a FOO pattern into body text of each file, then replace it to foo pattern (only the first match) . I did it because I've some hundreds of OOO3 Writer files where I did need to edit one word in each ones and open up each file in OOO3 gui wasn't an option. Usage: bsro3 FOO foo
Please be careful while executing the following command as you don?t want
to delete the files by mistake. The best practice is to execute the same
command with ls ?l to make sure you know which files will get deleted when
you execute the command with rm.
This is a simple solution to running a remote program on a remote computer on the remote display through ssh.
1. Create an empty 'commander' file in the directory where you intend on running these commands.
2. Run the command
3. Hop on another computer and ssh in to the PC where you ran the command
4. cd to the directory where the 'commander' file is.
5. Test it by doing the following: echo "xeyes" > commander
6. If it worked properly, then xeyes will popup on the remote computer.
Combined with my other one liner, you can place those in some start-up scripts and be able to screw with your wife/daughter/siblings, w/e by either launching programs or sending notifications(my other one liner).
Also, creates a log file named comm_log in working directory that logs all commands ran.
Run this command when you are physically at the computer you wish to send pop-up messages to. Then when you ssh in to it, you can do this: echo "guess who?" > commander
guess who? will then pop up on the screen for a few moments, then disappear. You will need to create the commander file first. I mess with my wife all the time with this. i.e. echo "You have given the computer a virus. Computer will be rendered useless in 10 seconds." > commander
lol
the command will calculate the size of hidden files
the command will not include hidden files
Finds all files below the current directory.
Orders the result from smallest to largest.
Good for finding the largest files in the tree.
find and normal files and list them sorting with modification time without group
l: with detailed information
t: sort with modification time
r: reverse order
h: show file's size in human-readable format, such as K(kilobytes), M(megabyes) etc.
g: do not show group
What *have* I been working on for the last 2 weeks...
List all files from the current directory and subdirectories, sorted by modification time, oldest first.