
Terminal - Commands using awk - 985 results
history | awk '{if ($2 == "sudo") a[$3]++; else a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn | head
This is sample output - yours may be different.
64 ifconfig
35 firefox
33 ls
29 ping
28 yaourt
27 history
25 cat
21 vim
19 /etc/rc.d/wireless
17 init
List of commands you use most often suppressing sudo
history | awk '{if ($2 == "sudo") a[$3]++; else a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn | head
This is sample output - yours may be different.
cp -p `ls -l | awk '/Apr 14/ {print $NF}'` /usr/users/backup_dir
This is sample output - yours may be different.
curl http://en.m.wikipedia.org/wiki/List_of_Internet_top-level_domains | grep "<tr valign=\"top\">" | awk -F">" '{ print $5 }' | awk -F"<" '{ print $1 }'
This is sample output - yours may be different.
.aero
.asia
.biz
.cat
.com
.coop
.info
.int
.jobs
.mobi
.museum
... ETC
Oneliner to get domain names list of all existing domain names (from wikipedia)
while sleep 1; do (mpc status;mpc currentsong)|awk 'BEGIN{FS=": "}/^Artist:/{r=r""$2};/^Title:/{r=r" - "$2};/^time:/{r=$2" "r};/^state: play/{f=1}END{if(f==1){print r}}'|echo -ne "\e[s\e[0;0H\e[K\e[0;44m\e[1;33m$(cat -)\e[0m\e[u";done &
This is sample output - yours may be different.
132:245 Front 242 - 7Rain [GHost]
Actually this is a shorter version that fits the 255 chars limit of this resource. The full version shows status in the right top corner:
alias mpdd='while sleep 1; do _r=$(awk '\''BEGIN{FS=": "}/^Artist:/{r=r""$2};/^Title:/{r=r" - "$2};/^time:/{r=$2" "r};/^state: play/{f=1}END{if(f==1){print r}}'\'' <(mpc status;mpc currentsong));_l=${#_r};[ $_l -eq 0 ] && continue;[ -z "$_p" ] && _p=$_l;echo -ne "\e[s\e[0;${_p}H\e[K\e[u";_p=$((COLUMNS - _l));echo -ne "\e[s\e[0;${_p}H\e[K\e[0;44m\e[1;33m${_r}\e[0m\e[u";done &'
mpc is defined like this:
function mpc() {
echo "$*" | nc 192.168.1.1 6600
}
/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'
This is sample output - yours may be different.
while true; do date; ps auxf | awk '{if($8=="D") print $0;}'; sleep 1; done
This is sample output - yours may be different.
ip addr show dev eth0 | awk '/inet/ {sub(/\//, " "); print $2}'
This is sample output - yours may be different.
No grep or sed overload, just pure awk.
for i in `eselect bashcomp list | awk '{print $2}'`; do eselect bashcomp enable $i; done
This is sample output - yours may be different.
ifconfig |grep broadcast | awk '{print $2}'
This is sample output - yours may be different.
get the ip address on your LAN
ifconfig |grep broadcast | awk '{print $2}'
This is sample output - yours may be different.
get the ip address on your LAN
ps -ef | awk -v OFS="\n" '{ for (i=8;i<=NF;i++) line = (line ? line FS : "") $i; print NR ":", $1, $2, $7, line, ""; line = "" }'
This is sample output - yours may be different.
1:
root
3410
00:00:00
gpm -m /dev/input/mice -t exps2
2:
root
3424
00:00:00
crond
3:
root
3488
00:00:00
/usr/sbin/atd
du . | sort -nr | awk '{split("KB MB GB TB", arr); idx=1; while ( $1 > 1024 ) { $1/=1024; idx++} printf "%10.2f",$1; print " " arr[idx] "\t" $2}' | head -25
This is sample output - yours may be different.
Lists the size in human readable form and lists the top 25 biggest directories/files
tail -1000 `ls -ltr /var/log/CF* |tail -1|awk '{print $9}'`|cut -d "," -f 17|sort|uniq -c |sort -k2
This is sample output - yours may be different.
count & sort one field of the log files , such as nginx/apache access log files .
ps -eo size,pid,user,command --sort -size |awk '{hr[1024**2]="GB";hr[1024]="MB";for (x=1024**3; x>=1024; x/=1024){if ($1>=x){printf ("%-6.2f %s ", $1/x, hr[x]);break}}}{printf ("%-6s %-10s ", $2, $3)}{for (x=4;x<=NF;x++){printf ("%s ",$x)} print ("\n")}'
This is sample output - yours may be different.
1.49 GB 6457 1001 /opt/google/chrome/chrome --type=renderer --lang=en-US --force-fieldtest=CacheListSize/CacheListSize_14/ConnCountImpact/conn_count_6/ConnnectBackupJobs/ConnectBackupJobsEnabled/DnsImpact/default_enabled_prefetch/DnsParallelism/parallel_default/GlobalSdch/global_enable_sdch/IdleSktToImpact/idle_timeout_10/Instant/HiddenExperimentB/Prefetch/ContentPrefetchPrerender2/PrerenderFromOmnibox/OmniboxPrerenderEnabled/PrerenderFromOmniboxHeuristic/ExactFullAlgorithm/ProxyConnectionImpact/proxy_connections_32/SpdyCwnd/cwnd10/SpdyImpact/npn_with_spdy/WarmSocketImpact/warmest_socket/ --extension-process --enable-print-preview --channel=6390.0xb9b71c60.593461523
630.18 MB 2488 1001 /usr/lib/thunderbird-3.1.8/thunderbird-bin
501.08 MB 3426 1001 /usr/lib/firefox-3.6.3/firefox-bin
272.55 MB 11897 1001 /usr/lib/chromium-browser/chromium-browser
Finding high memory usage report in human readable format.
cd ~/.msf4/loot && cat *mscache* | cut -d '"' -f 2,4 | sed s/\"/\:/g | tr -cd '\11\12\40-\176' | grep -v Username | cut -d : -f 1,2 | awk -F':' '{print $2,$1}' | sed 's/ /:/g' > final.dcc.hash
This is sample output - yours may be different.
pacman -Qi | grep 'Name\|Size\|Description' | cut -d: -f2 | paste - - - | awk -F'\t' '{ print $2, "\t", $1, "\t", $3 }' | sort -rn
This is sample output - yours may be different.
253888.00 KiB wine A compatibility layer for running Windows programs
241743.00 KiB libreoffice-common common files for LibreOffice - a productivity suite that is compatible with other major office suites
121212.00 KiB openjdk6 Free Java environment based on OpenJDK 6.0 with IcedTea6 replacing binary plugs.
108232.00 KiB chromium The open-source project behind Google Chrome, an attempt at creating a safer, faster, and more stable browser
This, like the other commands listed here, displays installed arch packages. Unlike the other ones this also displays the short description so you can see what that package does without having to go to google. It also shows the largest packages on top. You can optionally pipe this through head to display an arbitrary number of the largest packages installed (e.g. ... | head -30 # for the largest 30 packages installed)
vim `git status | grep modified | awk '{print $3}'`
This is sample output - yours may be different.
This oneliner gets all the 'modified' files in your git repository, and opens all of them in vim.
Very handy when you're starting to work in the morning and you simply want to review your modified files before committing them.
Maybe there are better ways to do that (and maybe integrated in vim and/or git, who knows), but I found quicker to do this oneliner.
awk '/^md/ {printf "%s: ", $1}; /blocks/ {print $NF}' </proc/mdstat
This is sample output - yours may be different.
find . -type f -print | awk -F'.' '{print $NF}' | sort | uniq -c
This is sample output - yours may be different.
identify path/to/image.jpg | awk '{print $3;}'
This is sample output - yours may be different.
for k in `git branch -r|awk '{print $1}'`;do echo -e `git show --pretty=format:"%Cgreen%ci_%C(blue)%c r_%Cred%cn_%Creset" $k|head -n 1`$k;done|sort -r|awk -F"_" '{printf("%s %17s %-22s %s\n",$1,$2,$3,$4)}'
This is sample output - yours may be different.
echo /home/foo/dir1/bar | awk -F/ -v OFS=/ '{$3 = "dir2"}1'
This is sample output - yours may be different.
$ echo /home/foo/dir1/bar | awk -F/ -v OFS=/ '{$3 = "dir2"}1'
/home/foo/dir2/bar
Awk replaces the value of a specific field while retaining the field separator "/" .
ls /var/log/sa/sa[0-9]*|xargs -I '{}' sar -u -f {}|awk '/^[0-9]/&&!/^12:00:01|RESTART|CPU/{print "%user: "$4" %system: "$6" %iowait: "$7" %nice: "$5" %idle: "$9}'|sort -nk10|head
This is sample output - yours may be different.
awk '{word=(substr($0,index($0,"blah"),5));print word}'
This is sample output - yours may be different.