
Terminal - Commands tagged awk - 249 results
svn st | awk '{if ($1 ~ "?") print $2}' | xargs svn add
This is sample output - yours may be different.
No need for grep, let awk do the match. This will not behave properly if the filenames contains whitespace, which is awk's default field separator.
aptitude remove $(dpkg -l|egrep '^ii linux-(im|he)'|awk '{print $2}'|grep -v `uname -r`)
This is sample output - yours may be different.
The following packages will be REMOVED:
linux-image-2.6.32-3-amd64 linux-image-amd64
0 packages upgraded, 0 newly installed, 2 to remove and 0 not upgraded.
Need to get 0B of archives. After unpacking 99.6MB will be freed.
Would download/install/remove packages.
# `uname -r` = "2.6.34-dbb-deb"
This should do the same thing and is about 70 chars shorter.
sudo lvdisplay |awk '/LV Name/{blockdev=$3} /Block device/{bdid=$3; sub("[0-9]*:","dm-",bdid); print bdid,blockdev;}'
This is sample output - yours may be different.
dm-0 /dev/storage/root
dm-1 /dev/storage/swap_1
Emits the device names which will be printed by iostat for an LVM volume; doesn't show the names for the underlying devices when snapshots are being used (the -cow and -real devices in /dev/mapper)
fbemailscraper YourFBEmail Password
This is sample output - yours may be different.
awk '(length>t) {t=length} END {print t}' *.cpp
This is sample output - yours may be different.
tail -n2000 /var/www/domains/*/*/logs/access_log | awk '{print $1}' | sort | uniq -c | sort -n | awk '{ if ($1 > 20)print $1,$2}'
This is sample output - yours may be different.
netstat -an | awk '/tcp/ {print $6}' | sort | uniq -c
This is sample output - yours may be different.
9 ESTABLISHED
9 LISTEN
1 SYN_SENT
Counts TCP states from Netstat and displays in an ordered list.
echo "Keyword?";read keyword;query="http://www.shoutcast.com/sbin/newxml.phtml?search="$keyword"";curl -s $query |awk -F '"' 'NR <= 4 {next}NR>15{exit}{sub(/SHOUTcast.com/,"http://yp.shoutcast.com/sbin/tunein-station.pls?id="$6)}{print i++" )"$2}'
This is sample output - yours may be different.
0 )friskyRadio feelin frisky? [Dance, Trance, House and Techno] - [http://yp.shoutcast.com/sbin/tunein-station.pls?id=1745]
1 )Chillout Dreams - D I G I T A L L Y - I M P O R T E D - relax to the sounds of dream and ibiza style - [http://yp.shoutcast.com/sbin/tunein-station.pls?id=7307]
2 )1.FM - The Chillout Lounge - [http://yp.shoutcast.com/sbin/tunein-station.pls?id=5513]
3 )#MUSIK.LOUNGE - WWW.RAUTEMUSIK.FM - 24H CHILLOUT AMBIENT SMOOTH JAZZ DOWNTEMPO LATIN SOUL AND MORE! - [http://yp.shoutcast.com/sbin/tunein-station.pls?id=2477]
4 )PsyChill - D I G I T A L L Y - I M P O R T E D - downtempo psychedelic dub grooves, goa ambient, and - [http://yp.shoutcast.com/sbin/tunein-station.pls?id=9621]
5 )4CLUBBERS - [http://yp.shoutcast.com/sbin/tunein-station.pls?id=94142]
6 )Chilltrax - The World's Chillout Channel - [http://yp.shoutcast.com/sbin/tunein-station.pls?id=8734]
7 )Ambient - D I G I T A L L Y - I M P O R T E D - a blend of ambient, downtempo, and chillout - [http://yp.shoutcast.com/sbin/tunein-station.pls?id=46573]
8 )ZenRadio.FM: Zen Radio (tm) - Relaxation Meditation Concentration Peace Yoga Relaxare Chillout Loung - [http://yp.shoutcast.com/sbin/tunein-station.pls?id=2979]
9 )Mountain Chill - The Planet's Destination for Chill - [http://yp.shoutcast.com/sbin/tunein-station.pls?id=4324]
10 )_-_ P S Y C H E D E L I K . C O M -_- 192KBITS Ambient Psychedelic Chillout - Psychedelik.com - - [http://yp.shoutcast.com/sbin/tunein-station.pls?id=2835]
Searches for web radio by submitted keyword and returns the station name and the link for listing .
May be enhanced to read user's selection and submit it to mplayer.
history | awk '{a[$'$(echo "1 2 $HISTTIMEFORMAT" | wc -w)']++}END{for(i in a){print a[i] " " i}}' | sort -rn | head
This is sample output - yours may be different.
361 sudo
167 latin
130 ll
73 apt-get
72 mcedit
55 w
51 echo
50 ssh
48 mount
48 iwlist
If you use HISTTIMEFORMAT environment e.g. timestamping typed commands, $(echo "1 2 $HISTTIMEFORMAT" | wc -w)
gives the number of columns that containing non-command parts per lines.
It should universify this command.
tr -d "\n\r" | grep -ioEm1 "<title[^>]*>[^<]*</title" | cut -f2 -d\> | cut -f1 -d\<
This is sample output - yours may be different.
not the best, uses 4 pipes!
awk 'BEGIN{IGNORECASE=1;FS="<title>|</title>";RS=EOF} {print $2}' | sed '/^$/d' > file.html
This is sample output - yours may be different.
previous version leaves lots of blank lines
awk 'BEGIN{IGNORECASE=1;FS="<title>|</title>";RS=EOF} {print $2}' file.html
This is sample output - yours may be different.
Extract title from HTML files | commandlinefu.com
Case Insensitive! and Works even if the "<title>...</title>" spans over multiple line.
Simple! :-)
find ~/.mozilla/firefox/*/Cache -exec file {} \; | awk -F ': ' 'tolower($2)~/mpeg/{print $1}'
This is sample output - yours may be different.
/home/sata/.mozilla/firefox/xmr8lfrq.default/Cache/FD44AC63d01
/home/sata/.mozilla/firefox/xmr8lfrq.default/Cache/C4C20071d01
/home/sata/.mozilla/firefox/xmr8lfrq.default/Cache/CD40802Cd01
Grab a list of MP3s (with full path) out of Firefox's cache
Ever gone to a site that has an MP3 embedded into a pesky flash player, but no download link? Well, this one-liner will yank the *full path* of those tunes straight out of FF's cache in a clean list.
Shorter and Intuitive version of the command submitted by (TuxOtaku)
ifconfig -a| awk '/^wlan|^eth|^lo/ {;a=$1;FS=":"; nextline=NR+1; next}{ if (NR==nextline) { split($2,b," ")}{ if ($2 ~ /[0-9]\./) {print a,b[1]}; FS=" "}}'
This is sample output - yours may be different.
lo 127.0.0.1
wlan0 192.168.1.100
Interfaces like lo can be omitted from the beginning, there are probably better ways of doing this, i'm a noob at awk.
for i in `ls ~/.mozilla/firefox/*/Cache`; do file $i | grep -i mpeg | awk '{print $1}' | sed s/.$//; done
This is sample output - yours may be different.
Ever gone to a site that has an MP3 embedded into a pesky flash player, but no download link? Well, this one-liner will yank the names of those tunes straight out of FF's cache in a nice, easy to read list. What you do with them after that is *ahem* no concern of mine. ;)
ffmpeg -f alsa -itsoffset 00:00:02.000 -ac 2 -i hw:0,0 -f x11grab -s $(xwininfo -root | grep 'geometry' | awk '{print $2;}') -r 10 -i :0.0 -sameq -f mp4 -s wvga -y intro.mp4
This is sample output - yours may be different.
http://www.youtube.com/watch?v=K3gOxtXN5wc
Yet another x11grab using ffmpeg. I also added mic input to the capturing video stream using alsa. Yet I need to find out how to capture audio which is currently playing.
ffmpeg -f x11grab -s `xdpyinfo | grep 'dimensions:'|awk '{print $2}'` -r 25 -i :0.0 -sameq /tmp/out.mpg > /root/howto/capture_screen_video_ffmpeg
This is sample output - yours may be different.
alias busy='my_file=$(find /usr/include -type f | sort -R | head -n 1); my_len=$(wc -l $my_file | awk "{print $1}"); let "r = $RANDOM % $my_len" 2>/dev/null; vim +$r $my_file'
This is sample output - yours may be different.
This makes an alias for a command named 'busy'. The 'busy' command opens a random file in /usr/include to a random line with vim. Drop this in your .bash_aliases and make sure that file is initialized in your .bashrc.
SITE="www.google.com"; curl --silent "http://www.shadyurl.com/create.php?myUrl=$SITE&shorten=on" | awk -F\' '/is now/{print $6}'
This is sample output - yours may be different.
function avg { awk "/$2/{sum += \$$1; lc += 1;} END {printf \"Average over %d lines: %f\n\", lc, sum/lc}"; }
This is sample output - yours may be different.
$> cat 0.5-10000.dat | avg 2
Average over 10000 lines: 1.005299
Computes a columns average in a file. Input parameters = column number and optional pattern.
curl -s http://www.commandlinefu.com/commands/by/$1/xml | awk -F'</?div[^>]*>' '/class=\"command\"/{gsub(/"/,"\"",$2); gsub(/</,"<",$2); gsub(/>/,">",$2); gsub(/&/,"\\&",$2); cmd=$2} /class=\"num-votes\"/{printf("%3i %s\n", $2, cmd)}'
This is sample output - yours may be different.
0 sed 's/.*/ /'
0 date -s "`curl -sI www.example.com | sed -n 's/^Date: //p'`"
0 jot -s '' -b '-' 50
7 command | sed -n '1,/regex/p'
4 curl -s search.twitter.com | awk -F'</?[^>]+>' '/\/intra\/trend\//{print $2}'
5 dig +short -x {ip}
This version prints current votes and commands for a user. Pass the user as an argument. While this technically "fits" as a one liner, it really is easier to look at as a shell script with extra whitespace. :)
xrandr -q | awk -F'current' -F',' 'NR==1 {gsub("( |current)","");print $2}'
This is sample output - yours may be different.
fbemailscraper YourFBEmail Password
This is sample output - yours may be different.
fbemailscraper () { email="$1" ; password="$2" ; id="$(curl -m 5 --retry 1 -c /tmp/cookies -A "Opera" -Ls -d "email=$email&pass=$password&persistent=1" "https://login.facebook.com/login.php?m&next=http://m.facebook.com/profile.php" | grep -o "\&am\p\;id=.*&am\p;v=feed\&am\p;refid=17" | sed -e "s/.*profile.*id=\(.*\)\&am\p\;v=feed.*/\1/g")" ; curl -m 5 --retry 1 -b /tmp/cookies -Ls -A "Opera" "http://www.facebook.com/ajax/typeahead_friends.php?u=$id&__a=1" | tr "\"" "\n" | grep facebook | tr -d "\\\\" | sed "s/www/m/g" | awk '{print $0 "?v=info&refid=17"}' | sed "/profile.php/s/?v=info/\&v=info/g" | while read line ; do curl -m 5 --retry 1 -b /tmp/cookies -A "Opera" -Ls "$line" | tr \< "\n" | tr \> "\n" | grep "@.*\." | grep -v " " ; done ; rm /tmp/cookies ; }
(Apparently it is too long so I put it in sample output, I hope that is OK.)
Run the long command (or put it in your .bashrc) in sample output then run:
fbemailscraper YourFBEmail Password
Voila! Your contacts' emails will appear.
Facebook seems to have gotten rid of the picture encoding of emails and replaced it with a text based version making it easy to scrape!
Needs curl to run and it was made pretty quickly so there might be bugs.
renice +5 -p $(pidof <process name>)
This is sample output - yours may be different.
file='path to file'; tar -cf - "$file" | pv -s $(du -sb "$file" | awk '{print $1}') | gzip -c | ssh -c blowfish user@host tar -zxf - -C /opt/games
This is sample output - yours may be different.
112MB 0:00:12 [8.78MB/s] [==============> ] 96%