Lauching an app including jars in an adjacent lib folder to its classpath
for file in `ls -t \`find . -name "*.zip" -type f\``; do found=`unzip -c "$file" | grep --color=always "PATTERN"`; if [[ $found ]]; then echo -e "${file}\n${found}\n"; fi done
Take a screenshot, give $1 seconds pause to choose what to screenshot, then upload and get URI of post in ompdlr.org Show Sample Output
A lot of files in one dir is not so cool for filesystem.
Actually this is a shorter version that fits the 255 chars limit of this resource. The full version shows status in the right top corner:
alias mpdd='while sleep 1; do _r=$(awk '\''BEGIN{FS=": "}/^Artist:/{r=r""$2};/^Title:/{r=r" - "$2};/^time:/{r=$2" "r};/^state: play/{f=1}END{if(f==1){print r}}'\'' <(mpc status;mpc currentsong));_l=${#_r};[ $_l -eq 0 ] && continue;[ -z "$_p" ] && _p=$_l;echo -ne "\e[s\e[0;${_p}H\e[K\e[u";_p=$((COLUMNS - _l));echo -ne "\e[s\e[0;${_p}H\e[K\e[0;44m\e[1;33m${_r}\e[0m\e[u";done &'
mpc is defined like this:
function mpc() {
echo "$*" | nc 192.168.1.1 6600
}
Show Sample Output
Something I pulled off 4chan, it plays a tune.
On CentOS at least, date returns a boolean for the common date string formats, including YYYY-MM-DD. In the sample output, you can see various invalid dates returning 0 whereas a simple regex check would return 1 for the invalid dates. -d, --date=STRING display time described by STRING, not `now' The version of date on OS X does not appear to have this same option. Show Sample Output
MAC OSX doesn't come with a locate command, This will do the same thing as the locate command on a typical Linux OS. Simply add it to your ~/.bash_profile
Kind of fun if you're that was inclined. I figured most of my commands start with s. sudo, screen, ssh etc. This script tells me what else they start with. Show Sample Output
it shows whether your CPU supports 64 bit (x86-64) mode. uname -a only shows whether you have 64 bit (x86-64) or 32bit (i386) OS installed, this one-liner answers question: Can I install 64bit OS on this machine?
Linux users wanting to extract text from PDF files in the current directory and its sub-directories can use this command. It requires "bash", "ps2ascii" and "par", and the PARINIT environment variable sanely set (see man par). WARNING: the file "junk.sh" will be created, run, and destroyed in the current directory, so you _must_ have sufficient rights. Edit the command if you need to avoid using the file name "junk.sh"
for use with virtualenvwrapper http://www.doughellmann.com/projects/virtualenvwrapper/
You can implement a FOR loop to act on one or more files returned from the IN clause. We originally found this in order to GPG decrypt a file using wildcards (where you don't know exactly the entire file name, i.e.: Test_File_??????.txt, where ?????? = the current time in HHMMSS format). Since we won't know the time the file was generated, we need to use wildcards. And as a result of GPG not handling wildcards, this is the perfect solution. Thought I would share this revelation. :-) Show Sample Output
I run this via crontab every one minute on my machine occasionally to see if a process is eating up my system's resources.
same as "unset HISTFILE" - but the advantage is that you can "tab-complete" it and when you do, you won't mistype it (which could lead to not unsetting the HISTFILE). put the alias in the ~/.bash_profile or ~/.bashrc file in your users home directory, respawn, enjoy! :) Show Sample Output
Avoids cat abuse ;)
While `echo rm * | batch` might seem to work, it might still raise the load of the system since `rm` will be _started_ when the load is low, but run for a long time. My proposed command executes a new `rm` execution once every minute when the load is small. Obviously, load could also be lower using `ionice`, but I still think this is a useful example for sequential batch jobs. Show Sample Output
make a bunch of files with the same permissions, owner, group, and content as a template file (handy if you have much to do w. .php, .html files or alike)
bash only - no grep, sed, awk, whatever - zero overhead alternatively using ifconfig instead of "ip addr ..." A=$(ifconfig eth0); A=${A##*inet addr:}; echo ${A%% *} Show Sample Output
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: