Troca de conhecimentos sobre o uso da linha de comando e referencia direta ao site commandlinefu.com.
Find Duplicate Files (based on size first, then MD5 hash)
20 de Setembro de 2009, 0:00 - sem comentários ainda$ find -not -empty -type f -printf "%s\n" | sort -rn | uniq -d | xargs -I{} -n1 find -type f -size {}c -print0 | xargs -0 md5sum | sort | uniq -w32 -D --all-repeated=separate
This dup finder saves time by comparing size first, then md5sum, it doesn't delete anything, just lists them.
by David Winterbottom (codeinthehole.com)
Show apps that use internet connection at the moment.
19 de Setembro de 2009, 0:00 - sem comentários ainda$ lsof -P -i -n | cut -f 1 -d " "| uniq | tail -n +2
show only the name of the apps that are using internet
by David Winterbottom (codeinthehole.com)
Show apps that use internet connection at the moment. (Multi-Language)
19 de Setembro de 2009, 0:00 - sem comentários ainda$ lsof -P -i -n
by David Winterbottom (codeinthehole.com)
redirect stdout and stderr each to separate files and print both to the screen
15 de Setembro de 2009, 0:00 - sem comentários ainda$ (some_command 2>&1 1>&3 | tee /path/to/errorlog ) 3>&1 1>&2 | tee /path/to/stdoutlog
by David Winterbottom (codeinthehole.com)
send echo to socket network
12 de Setembro de 2009, 0:00 - sem comentários ainda$ echo "foo" > /dev/tcp/192.168.1.2/25
this command will send a message to the socket 25 on host 192.168.1.2 in tcp.
works on udp and icmp
understand only IP address, not hostname.
on the other side (192.168.1.2), you can listen to this socket and test if you receive the message.
easy to diagnose a firewall problem or not.
by David Winterbottom (codeinthehole.com)
Identify long lines in a file
10 de Setembro de 2009, 0:00 - sem comentários ainda$ awk 'length>72' file
This command displays a list of lines that are longer than 72 characters. I use this command to identify those lines in my scripts and cut them short the way I like it.
by David Winterbottom (codeinthehole.com)
View a terminal session remotely (helpdesks etc, like vncviewer but for terminals!)
9 de Setembro de 2009, 0:00 - sem comentários ainda$ mkfifo ~/session; script -f ~/session
Type the command above in a terminal session on machine1, then on a remote machine2 do:
ssh ip.of.machine1 -l username cat session
Now, whatever is typed/displayed on machine1 terminal session is displayed on machine2!
Including cool stuff like http://www.commandlinefu.com/commands/view/3348/cycle-through-a-256-colour-palette
If terminal sizes are different, output may not always be correctly formatted. Ctrl-D on machine1 to end session
(If you don't have a remote machine to test from, just run 'cat session' in another terminal window to see the effect)
by David Winterbottom (codeinthehole.com)
check open ports
9 de Setembro de 2009, 0:00 - sem comentários ainda$ lsof -Pni4 | grep LISTEN
Tested in Linux and OSX
by David Winterbottom (codeinthehole.com)
Check your unread Gmail from the command line
8 de Setembro de 2009, 0:00 - sem comentários ainda$ curl -u username:password --silent "https://mail.google.com/mail/feed/atom" | tr -d '\n' | awk -F '<entry>' '{for (i=2; i<=NF; i++) {print $i}}' | sed -n "s/<title>\(.*\)<\/title.*name>\(.*\)<\/name>.*/\2 - \1/p"
Checks the Gmail ATOM feed for your account, parses it and outputs a list of unread messages.
For some reason sed gets stuck on OS X, so here's a Perl version for the Mac:
curl -u username:password --silent "https://mail.google.com/mail/feed/atom" | tr -d '\n' | awk -F '<entry>' '{for (i=2; i<=NF; i++) {print $i}}' | perl -pe 's/^<title>(.*)<\/title>.*<name>(.*)<\/name>.*$/$2 - $1/'
by David Winterbottom (codeinthehole.com)
Get your external IP address
6 de Setembro de 2009, 0:00 - sem comentários ainda$ curl -s 'http://checkip.dyndns.org' | sed 's/.*Current IP Address: \([0-9\.]*\).*/\1/g'
by David Winterbottom (codeinthehole.com)