If BREs can be used, this sed version will also get the job done.
puts command in background and sends its output to nohup.out file it will not die if you log out fromyour shell session ;-)
Run this before you run a command in order to see what the command does as it starts. The -c flag is useful here as the PID is unknown before startup. All config files, libraries, logs, ports, etc used by the command as it starts up, (and shuts down) will be captured at 1s intervals and written to a file. Useful for debugging etc. Show Sample Output
faster ;) but your idea is really cool
or "Execute a command with a timeout"
Run a command in background, sleep 10 seconds, kill it.
! is the process id of the most recently executed background command.
You can test it with:
find /& sleep10; kill $!
Example :
LC_ALL=C man less | less +/ppattern
Same as the cool matrix style command ( http://www.commandlinefu.com/commands/view/3652/matrix-style ), except replacing the printed character with randomness. The command mentioned is much faster and thus more true to the matrix. However, mine can be optimized, but I wasted ... i mean spent enough time on it already Show Sample Output
preferred way to query ps for a specific process name (not supported with all flavors of ps, but will work on just about any linux afaik) Show Sample Output
Possible use, to filter something in stderr: (/usr/bin/$COMMAND $PARAM 3>&1 1>&2 2>&3 | grep -v $uninteresting_error ) 3>&1 1>&2 2>&3
You can use this on your session login.
Tested in Gnome 3.4
This makes your commandlinefu.com's favorites appear as most recent commands in your history.
This is a two part command that comes in really handy if you're running commands that take longer than you're willing to wait. The commands are separated by the semicolon(;) The first command is whatever you're attempting to do. The second commands emails you after the job completes. Show Sample Output
":! ls -l " results in listing the files in the current directory. pressing "enter" will get you back into vi.
The improvement is that you can re-attach to the screen at a later point.
In this example the command "somecommand" will be executed and sent a SIGALARM signal if it runs for more than 10 seconds. It uses the perl alarm function. It's not 100% accurate on timing, but close enough. I found this really useful when executing scripts and commands that I knew might hang E.g. ones that connect to services that might not be running. Importantly this can be used within a sequential script. The command will not release control until either the command completes or the timeout is hit. Show Sample Output
'jot' does not come with most *nix distros, so we need to use seq to make it work. This version tested good on Fedora 11.
The whatis command displays a short description for the command you list on the command line. It is useful to quickly learn what a command does Show Sample Output
Are there any creative pieces of music that can be created using beep and the shell? I'd love to hear it!
grep ERROR *.log
-bash: /bin/grep: Argument list too long
echo *.log | xargs grep ERROR /dev/null
20090119.00011.log:DANGEROUS ERROR
The last ; is important. example: time { rm -rf /folder/bar && mkdir -p /folder/bar ; echo "done" ; } command is a bash builtin Show Sample Output
Example: fuman sed Show Sample Output
Place in ~/.bashrc If you login to a ssh server from different ips, sometimes you want to do something specific for each. e.g., quickly go into screen -x session from a phone, but not your desktop.
commandlinefu.com is the place to record those command-line gems that you return to again and again. 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.
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: