see summary. if you want to set dpi right away try this: xrandr --query | sed -n 's@\([A-Z0-1-]*\).* \(.*\)x\(.*\)+.*+.* \([0-9]\+\)mm x \([0-9]\+\)mm@"--output \1 --dpi ";(\2/\4+\3/\5)*12.7@p;'|bc -l|xargs -L1 xrandr all syntax should be POSIX compliant. Show Sample Output
ditto can be used to "thinnify" Mach-O Universal binaries to separate unncessary code from your machine. For example, doubleTwist.app shaved off around 10 MB while Google Earth went from 112 MB to 62 MB after extracting only the i386 code from them.
Thanks th John_W for suggesting the fix allowing ~/ to be used when saving a directory. directions: Type in a url, it will show a preview of what the file will look like when saved, then asks if you want to save the preview and where you want to save it. Great for grabbing the latest commandlinefu commands without a full web browser or even a GUI. Requires: w3m Show Sample Output
In order to create, let's say, 10 directories with a single process we can use the command:
mkdir test{1,2,3,4,5,6,7,8,9,10}
something extremely boring to type! Why not use seq?
seq -s, 1 10
and use its output inside the curly braces?
The obvious solution
mkdir test{$(seq -s, 1 10)}
is, unfortunately, too naive and doesn't work. The answer is the order of the shell expansions (feature of Bourne Shell, actually), where brace expansion happens before command substitution (according to Bash's manual).
The solution is to put another level of substitution, using the powerful and mystic command eval.
I found the trick in a similar problem in the post at http://stackoverflow.com/questions/6549037/bash-brace-expansion-in-scripts-not-working-due-to-unwanted-escaping
Can't print correctly in the command field.
There is a new line before } as follows
seq 20 | sed -n '5,6 { w out.txt
}'
Show Sample Output
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
This keeps the user logged in but shows the login screen. Very useful when connecting remotely to an OSX-Server via VNC
Use awk to sum and print the space used by a group of files. It works well as long as the space used is not bigger than 79094548.80... I found that upper limit when trying to find out what was the total amount of recoverable space from a set of directories: user@servername:/home/user/scripts>for dirName in aleph_bin aleph_sh aleph_work dailycheck INTERFAZ ; do echo "${dirName} = $(cat /tmp/purge_ocfs_dir.*.log | awk '{sum+=$5} END {printf "%4.2f", sum}') "; done aleph_bin = 79094548.80 aleph_sh = 79094548.80 aleph_work = 79094548.80 dailycheck = 79094548.80 INTERFAZ = 79094548.80 In the worst case scenario, the total number might be almost 137G. user@servername:/home/user/scripts>df -h /ocfs/* Filesystem Size Used Avail Use% Mounted on //argalephfsprod/aleph_bin$ 137G 38G 99G 28% /ocfs/aleph_bin //argalephfsprod/aleph_sh$ 137G 38G 99G 28% /ocfs/aleph_sh //argalephfsprod/aleph_work$ 280G 135G 146G 49% /ocfs/aleph_work //argalephfsprod/dailycheck$ 137G 38G 99G 28% /ocfs/dailycheck //argalephfsprod/INTERFAZ/ 137G 38G 99G 28% /ocfs/INTERFAZ Any suggestion about how to get the correct amount of space for total over 80 Mbytes? Show Sample Output
Sure, it's dirty, but it's quick, it only displays the excuse, and it works. Show Sample Output
List all font names installed in the system. Useful for TeX. Show Sample Output
Stat -c %n #list files. A find command is also useful Tee #use stdout, but reseend to next comand. Can be other Tee ad infinitum xargs #use de name of files to execute md5 and sha diggest.
generates two file id_rsa (private) and id_rsa.pub
check web server port 80 response header Show Sample Output
When nvidia-settings gets itself into a funk and displays the error "Unable to load X Server Display Configuration page", then use this script to make it reset itself. reference: http://ubuntuforums.org/archive/index.php/t-1047029.html 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: