Combining find and grep

Quick note to remember this syntax as every few months I find a need to do a grep within a number of files:

find -name "pattern" -exec grep "pattern" {} ;

Grep options:
-H print filename in results
-n print line number where match was found
-l limit match to first found match in file (useful if you want to find files containing a match but don’t care how many matches are in each file)

Pipe to wc -l to count file occurrences, eg:

find -name "pattern" -exec grep -l "pattern" {} ; | wc -l

Use egrep if you need to use regex in the pattern.

Raspberry Pi Raspbian wifi dongle network config

There’s probably many ways you could configure a similar setup to this, but here’s what worked for me.

This is for static IP on wired, and a different static IP on wireless, where the wireless is using WPA2. I also have two different routers one for wired and for one wireless. Replace static_ip_here with your required ip addresses, and x and y with the IP addresses for your routers.

Edit /etc/network/interfaces:

auto lo
iface lo inet loopback
iface eth0 inet static
address 192.168.1.static_ip_here
netmask 255.255.255.0
gateway 192.168.1.x

allow-hotplug wlan0
iface wlan0 inet static
address 192.168.0.static_ip_here
netmask 255.255.255.0
gateway 192.168.0.y
wpa-ssid "your_ssid"
wpa-psk "your passphrase"
wpa-pairwise CCMP
wpa-group CCMP

tmux useful commands

tmux is a great alternative to screen if you’re looking for multiple virtual sessions in one terminal window.

Useful commands:

Ctrl-b c : open new session

Ctrl-b n | p : cycle next / previous through sessions

Ctrl-b % | ” : split horizontally / vertically

Ctrl-b left | right | up |down : cycle back /forward through visible split windows (left/right if split horizontally, up/down if split vertically)

Using Putty SSH, if you’re not getting line characters for the splits, change session charset to UTF8.