Thursday, October 6, 2011

OSX commands equivalent to Linux commands

OSX Linux
==== =====
disktool -l fdisk -l

Friday, September 23, 2011


Grep for IP Addresses:
Only the IP:
grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' file.txt

Only one IP and ONLY if it is at the beginning of the line:
grep '^[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}$' file.txt

Any IP and the rest of the line it is one:
grep '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' file.txt

Convert sequential lines of text to space delimitated list:
perl -pe 's/\s*$/ /' filename.txt

Sort IP's properly:
sort -t . -k 1,1n -k 2,2n -k 3,3n -k 4,4n

Display only unique IP's from above sort command:
| uniq

Remove all white space from left to first word:
cat | sed -e 's/^[ \t]*//'