Thursday, June 2, 2011

grep, sed, awk ...

Search TEX files for \label commands and check for double ref:

cat *.tex | grep "label{" | sed 's/.*{\(.*\)}.*/\1/' | uniq -c | sort -n


extract the IP address from ifconfig

$ ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:13:72:BE:FF:63
inet addr:172.19.65.12 Bcast:172.19.79.255 Mask:255.255.240.0
inet6 addr: fe80::213:72ff:febe:ff63/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:4801968 errors:0 dropped:0 overruns:0 frame:0
TX packets:1088918 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2559338610 (2.3 GiB) TX bytes:90195114 (86.0 MiB)
Interrupt:16

$ ifconfig eth0 | awk '/inet addr/ {FS=" "; gsub("addr:","",$2); print $2}'
172.19.65.12

No comments:

Post a Comment