
Terminal - Commands using awk - 1,218 results
awk -F":" '{ print $1 }' /etc/passwd | while read UU ; do STATUS=$(passwd -S ${UU} | grep locked 2>/dev/null) ; if [[ ! -z ${STATUS} ]] ; then echo "Account ${UU} is locked." ; fi ; done
This is sample output - yours may be different.
echo $LS_COLORS | sed 's/:/\n/g' | awk -F= '!/^$/{printf("%s \x1b[%smdemo\x1b[0m\n",$0,$2)}'
This is sample output - yours may be different.
This can show all ls colors, with a demo.
zcat access_log.*.gz | awk '{print $7}' | sort | uniq -c | sort -n | tail -n 20
This is sample output - yours may be different.
curl -sL 'dynamic.xkcd.com/comic/random/' | awk -F\" '/^<img/{printf("<?xml version=\"1.0\"?>\n<xkcd>\n<item>\n <title>%s</title>\n <comment>%s</comment>\n <image>%s</image>\n</item>\n</xkcd>\n", $6, $4, $2)}'
This is sample output - yours may be different.
wget -q http://dynamic.xkcd.com/comic/random/ -O-| sed -n '/<img src="http:\/\/imgs.xkcd.com\/comics/{s/.*\(http:.*\)" t.*/\1/;p}' | awk '{system ("wget -q " $1 " -O- | display -title $(basename " $1") -write /tmp/$(basename " $1")");}'
This is sample output - yours may be different.
Only need to install Image Magick package.
Display a xkcd comic with its title and save it in /tmp directory
If you prefer to view the newest xkcd, use this command:
wget -q http://xkcd.com/ -O-| sed -n '/<img src="http:\/\/imgs.xkcd.com\/comics/{s/.*\(http:.*\)" t.*/\1/;p}' | awk '{system ("wget -q " $1 " -O- | display -title $(basename " $1") -write /tmp/$(basename " $1")");}'
traceroute 2>/dev/null -n google.com | awk '/^ *1/{print $2;exit}'
This is sample output - yours may be different.
ps ax| awk '/[h]ttpd/{print $1}'| xargs kill -9
This is sample output - yours may be different.
for i in `mysqladmin -h x.x.x.x --user=root -pXXXX processlist | grep <<username>>| grep <<Locked>>| awk {'print $2'}` do mysqladmin -h x.x.x.x --user=root -pXXX kill $i; done;
This is sample output - yours may be different.
ps aux| grep -v grep| grep httpd| awk {'print $2'}| xargs kill -9
This is sample output - yours may be different.
ipcalc $(ifconfig eth0 | grep "inet addr:" | cut -d':' -f2,4 | sed 's/.+Bcast:/\//g') | awk '/Network/ { print $2 } '
This is sample output - yours may be different.
awk '/inet end/ {print $3}' <(ifconfig eth0)
This is sample output - yours may be different.
awk 'NR==2 {print $1}' /proc/net/arp
This is sample output - yours may be different.
ifconfig -a| awk 'BEGIN{FS="[ :]+"} /Bcast/{print $4}'
This is sample output - yours may be different.
ifconfig -a|grep Bcast:|cut -d\: -f2|awk '{print $1}'
This is sample output - yours may be different.
grabs your local IP Address.
/usr/sbin/ifconfig -a|awk -F" " 'NR==4{print $2}'
This is sample output - yours may be different.
curl -s 'xkcd.com' | awk -F\" '/^<img/{printf("<?xml version=\"1.0\"?>\n<xkcd>\n<item>\n <title>%s</title>\n <comment>%s</comment>\n <image>%s</image>\n</item>\n</xkcd>\n", $6, $4, $2)}'
This is sample output - yours may be different.
<?xml version="1.0"?>
<xkcd>
<item>
<title>Spinal Tap Amps</title>
<comment>Wow, that's less than $200 per ... uh ... that's a good deal!</comment>
<image>http://imgs.xkcd.com/comics/spinal_tap_amps.png</image>
</item>
</xkcd>
I wasn't sure how to display the image, so I thought I'd try xml for a different twist.
lynx --dump --source http://www.xkcd.com | grep `lynx --dump http://www.xkcd.com | egrep '(png|jpg)'` | grep title | cut -d = -f2,3 | cut -d '"' -f2,4 | sed -e 's/"/|/g' | awk -F"|" ' { system("display " $1);system("echo "$2); } '
This is sample output - yours may be different.
Same thing just a different way to get there. You will need lynx
dd if=/dev/zero of=/fs/to/fill/dummy00 bs=8192 count=$(df --block-size=8192 / | awk 'NR!=1 {print $4-100}')
This is sample output - yours may be different.
For disk space constraint testing. Leaves a little space available for creating temp files, etc. Easily free up the used disk space again by deleting the dummy00 file. Can tailor the testing by building smaller 'blocks' to suit the needs of the testing.
WARNING: do not do this to the '/' (root) filesystem unless you know what you are doing... on some systems it could crash the OS.
MYSQL="mysql -h HOST -u USERNAME -pPASSWORD -D DB_NAME" ; $MYSQL -BNe "show tables" | awk '{print "set foreign_key_checks=0; drop table `" $1 "`;"}' | $MYSQL unset MYSQL
This is sample output - yours may be different.
awk '/<link>/{gsub(/.*<link>|<\/link>.*/,"");print "<li><a href=\042"$0"\042> "t"</a>" } /<title>/{gsub(/.*<title>|<\/title>.*/,"");t=$0 }' file
This is sample output - yours may be different.
you can just use one awk script to parse the rss feed. No need to pipe so many awk's and sed's. Its ugly and inefficient.
egrep "<link>|<title>" recenttracks.rss | awk 'ORS=NR%2?" ":"\n"' | awk -F "</title>" '{print $2, $1}' | sed -e 's/\<link\>/\<li\>\<a href\=\"/' -e 's/\<\/link\>/\">/' -e 's/\<title\>//' -e 's/$/\<\/a\>\<\/li\>/g' -e '1,1d' -e 's/^[ \t]*//'
This is sample output - yours may be different.
<li><a href="http://www.last.fm/music/Morton+Feldman/_/Something+Wild"> Morton Feldman ? Something Wild</a></li>
<li><a href="http://www.last.fm/music/Christopher+Bissonnette/_/Pellucidity"> Christopher Bissonnette ? Pellucidity</a></li>
Quick and kludgy rss parser for the recent tracks rss feed from last.fm. Extracts artist and track link.
cho "(Something like http://foo.com/blah_blah)" | awk '{for(i=1;i<=NF;i++){if($i~/^(http|ftp):\/\//)print $i}}'
This is sample output - yours may be different.
don't have to be that complicated
netstat | awk '/EST/{print $5}' | sort
This is sample output - yours may be different.
no need grep. its redundant when awk is present.
netstat | grep EST | awk '{print $5}' | sort
This is sample output - yours may be different.
Sometimes I need a quick visual way to determine if there is a particular server who is opening too many connections to the database machine.
ls -l `ls -l |awk '/^l/ {print $8}'`
This is sample output - yours may be different.
ls -l may vary depending on operating system, so "print $8" may have to be changed