Mac OSX one-liners to get specific IP Info

I needed to allow users to print very specific networking information with ease.
A typical user doesn’t want to decipher all of the extra info and steps an ifconfig or similar command can bring.
While building this script, I ended up with quite a few one-liners that could be useful for every day admin tasks

Print ONLY IP Address
ipconfig getifaddr en0

print ONLY Gateway
route -n get default | awk '/gateway: / {print $2;} '

print ONLY Network Mask for Wi-Fi connection
networksetup -getinfo "Wi-Fi" | awk '/Subnet mask:/ {print $3;} '

print ONLY Network Address
ip=$(ipconfig getifaddr en0) && nm=$(networksetup -getinfo "Wi-Fi" | awk '/Subnet mask:/ {print $3;} ') && IFS=. read -r i1 i2 i3 i4 <<< "$ip" && IFS=. read -r m1 m2 m3 m4 <<< "$nm" && printf "%d.%d.%d.%d\n" "$((i1 & m1))" "$(($i2 & m2))" "$((i3 & m3))" "$((i4 & m4))"

Print all DNS servers on one line
cat /etc/resolv.conf | awk '/nameserver / {print $2;} ' | tr "\n" " "

Delete .DS_Store files

OSX Finder automatically creates DS_Store files when you browse to a directory. The DS_Store file contains information about custom attributes in a folder like the position of icons or the choice of a background image. Uploading it with other files opens the risk of outside users to obtain information about your computer or just create unneeded clutter

Often times when I want to FTP upload a directory it will have a .DS_Store file at the root of each folder.
I of course don’t want this uploaded with my FTP transfer.
Execute this command in the folder you want to delete all .DS_Store files from

sudo find . -name ".DS_Store" -depth -exec rm {} \;