### Commands by techie (33) the last day the last week the last month all time sorted by date votes

• -7
Shift ZZ
· 2013-06-06 14:33:44

• -6
pwgen -Bs 10 1
· 2013-05-16 10:50:00
• In the sample output I used google.com. Show Sample Output

-13
mtr <URL>
· 2013-05-10 09:48:23

• -8
ls *.jpg | xargs -n1 -i cp {} /external-hard-drive/directory
· 2013-05-09 08:33:01

• -9
vim -R /etc/passwd
· 2013-05-09 08:28:32

• -5
vim +143 filename.txt
· 2013-05-09 08:24:28

• 0
awk '!($0 in array) { array[$0]; print }' temp
· 2013-05-09 08:23:30

• -4
sed -n '1!G;h;$p' techie.txt · 2013-05-09 08:22:36 • -8 find -iname "MyCProgram.c" -exec md5sum {} \; · 2013-05-09 08:21:18 • -6 grep -A 3 -i "example" demo_text · 2013-05-09 08:20:31 • -5 netstat -nlput · 2013-05-09 08:15:04 • -4 nethogs · 2013-05-07 15:09:55 • -4 iotop · 2013-05-07 15:06:05 • -2 watch w · 2013-05-07 15:02:41 • -5 shred -v filename · 2013-05-07 14:58:17 • -3 renice -20 -g 2874 (2784 found with ps -Aj) · 2013-05-07 14:55:42 • -4 cat /dev/ttyS2 | hexdump -C · 2013-05-07 14:54:37 • if you cd into a directory then cd into another directory somewhere else then you run the cd - command you will go to the previous directory you was in!! To go back to the other directory just run it again. So if you are working in 2 different directories then this is the perfect command for you. -7 cd - · 2013-05-07 14:50:18 • -4 nc -w 5 -v -l -p 80 < file.ext · 2013-04-29 14:39:59 • -2 find -maxdepth 1 -type d | while read dir; do echo$dir; echo cmd2; done
· 2013-04-29 10:15:13
• Now all you have to do is replace user by your twitter username , pass by your password and the text inside status to whatever you wish to set your status too . It uses cUrl library to post your messsage

-5
curl -u user:pass -d status=?I am Tweeting from the shell? http://twitter.com/statuses/update.xml
· 2013-04-29 10:12:43

• -5
echo ?ls -l? | at midnight
· 2013-04-29 10:11:35

• -5
echo ?ls -l? | at 10am Jul 21
· 2013-04-29 10:11:01

• -4
find /etc -exec grep '[0-9][0-9]*[.][0-9][0-9]*[.][0-9][0-9]*[.][0-9][0-9]*' {} \;
· 2013-04-29 10:10:11
• I know how hard it is to find an old command running through all the files because you couldn't remember for your life what it was. Heres the solution!! Grep the history for it. depending on how old the command you can head or tail or if you wanted to search all because you cannot think how long ago it was then miss out the middle part of the command. This is a very easy and effective way to find that command you are looking for.

-9
cat .bash_history | tail -100 | grep {command}
· 2013-04-10 10:40:52
•  1 2 >

### What's this?

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.

### Check These Out

C one-liners
$/lib/ld-linux.so.2 is the runtime linker/loader for ELF binaries on Linux. =(cmd) is a zsh trick to take the output for the command "inside" it and save it to a temporary file.$ echo -e 'blah' | gcc -x c -o /dev/stdout - pipes the C source to gcc. -x c tells gcc that it's compiling C (which is required if it's reading from a pipe). -o /dev/stdout - tells it to write the binary to standard output and read the source from standard input. because of the the =() thing, the compiled output is stashed in a tempfile, which the loader then runs and executes, and the shell tosses the tempfile away immediately after running it.

Job Control
background and disown, but with a proper one-line syntax

check open ports without netstat or lsof

Convert seconds to [DD:][HH:]MM:SS
Converts any number of seconds into days, hours, minutes and seconds. sec2dhms() { declare -i SS="$1" D=$(( SS / 86400 )) H=$(( SS % 86400 / 3600 )) M=$(( SS % 3600 / 60 )) S=$(( SS % 60 )) [ "$D" -gt 0 ] && echo -n "${D}:" [ "$H" -gt 0 ] && printf "%02g:" "$H" printf "%02g:%02g\n" "$M" "$S" } Check if x86 Solaris based system is 32bit or 64bit This is likely only valid on Solaris based systems. Unfortunately a lot of the more universal techniques for determining if a system is 32bit or 64bit on x86 solaris fail to give much more information than "i86pc" View Processeses like a fu, fu I don't truly enjoy many commands more than this one, which I alias to be ps1.. Cool to be able to see the heirarchy and makes it clearer what need to be killed, and whats really going on. use the real 'rm', distribution brain-damage notwithstanding The backslash avoids any 'rm' alias that might be present and runs the 'rm' command in$PATH instead. In a misguided attempt to be more "friendly", some Linux distributions (or sites/etc.) alias 'rm' to 'rm -i'. Unfortunately, this trains users to expect that files won't actually be deleted until they okay it. This expectation will fail with catastrophic results when they use other distributions, move to other sites, etc., and doesn't really even work 100% even with the alias. It's too late to fix 'rm', but '\rm' should work everywhere (under bash).

Remove newlines from output
Pipe any output to "grep ." and blank lines will not be printed.

Rename files in batch

Show whats going on restoring files from a spectrum protect backup
spectrum protect's dsmc command shows file names and total amount of restore. This command shows which files are actually open and their siz in GB and highlights the change to the previous output