Commands using head (259)

  • Access www.kernel.org and download the last stable linux kernel release. Show Sample Output


    0
    wget --no-check-certificate https://www.kernel.org/$(wget -qO- --no-check-certificate https://www.kernel.org | grep tar | head -n1 | cut -d\" -f2)
    glaudiston · 2013-11-07 18:46:14 0
  • Sorts by latest modified files by looking to current directory and all subdirectories Show Sample Output


    1
    find . -name '*pdf*' -print0 | xargs -0 ls -lt | head -20
    fuats · 2013-10-03 21:58:51 0

  • 0
    du -ah | sort -hr | head -n50 | cat -n
    rgregor · 2013-10-01 10:16:13 0
  • Use less random number resources and less commands


    0
    head -c 24 /dev/urandom | base64
    henix · 2013-09-28 16:32:47 0
  • Took one of the samples, added capitalization and removes in between spaces. The final "echo" is just for readability. Cheers Show Sample Output


    0
    shuf /usr/share/dict/words |grep "^[^']\{3,6\}$" |head -n4 | sed -e "s/\b\(.\)/\u\1/g" | tr -d '\n'; echo
    chijonutor · 2013-09-06 03:05:31 0

  • 0
    host example.com | head -1 | awk '{print $4}'
    wes · 2013-09-05 22:20:49 0
  • I'm not sure how reliable this command is, but it works for my needs. Here's also a variant using grep. nslookup www.example.com | grep "^Address: " | awk '{print $2}' Show Sample Output


    1
    nslookup www.example.com | tail -2 | head -1 | awk '{print $2}'
    wsams · 2013-09-05 20:26:45 3
  • Pipes the header row of ps to STDERR, then greps for the command on the output of ps, removing the grep entry before that. Show Sample Output


    0
    psgrep() { ps aux | tee >(head -1>&2) | grep -v " grep $@" | grep "$@" -i --color=auto; }
    fnl · 2013-08-02 12:44:32 0
  • bash-3.2$ find /logs -ls -xdev | sort -nrk 7 | head -10 1761905 205380 -rwxrwxr-x 1 wsadmin logadmin 210095353 Jul 22 01:33 /logs/intlpymt/Trace.log 652689 187360 -rwxrwxr-x 1 wsadmin logadmin 191663182 Jul 21 23:00 /logs/websphere/wsfpp1lppwa1213omsecureServer/SystemOut_13.07.21_23.00.12.log 2380449 186536 -rwxrwxr-x 1 wsadmin logadmin 190819939 Jul 16 14:03 /logs/omset/traceIntl.log.201307161403.lppwa1213.gz 2119524 183888 -rwxrwxr-x 1 wsadmin logadmin 188110111 Jul 22 01:33 /logs/intlpymt/intlpymtria/Trace.log 652816 160332 -rwxrwxr-x 1 wsadmin logadmin 164011871 Aug 14 2012 /logs/websphere/wsfpp1lppwa1213omsecureServer/SystemOut.log_08142012.gzip 653312 128916 -rwxrwxr-x 1 wsadmin logadmin 131873943 Jul 18 10:49 /logs/websphere/heapdump.20130718.104150.27592.0006.phd.201307181406.lppwa1213.gz 653320 128916 -rwxrwxr-x 1 wsadmin logadmin 131873735 Jul 18 10:40 /logs/websphere/heapdump.20130718.104012.27592.0002.phd.201307181406.lppwa1213.gz 653309 128912 -rwxrwxr-x 1 wsadmin logadmin 131867602 Jul 18 10:46 /logs/websphere/heapdump.20130718.104008.27592.0001.phd.201307181405.lppwa1213.gz 653323 128872 -rwxrwxr-x 1 wsadmin logadmin 131828157 Jul 18 10:41 /logs/websphere/heapdump.20130718.104109.27592.0004.phd.201307181407.lppwa1213.gz 652783 120288 -rwxrwxr-x 1 wsadmin logadmin 123047750 Aug 13 2012 /logs/websphere/wsfpp1lppwa1213omsecureServer/SystemOut.log_0813.2012.gzip bash-3.2$ Show Sample Output


    0
    find /logs -ls -xdev | sort -nrk 7 | head -10
    vidya99343 · 2013-07-22 08:36:03 0

  • 0
    find /logs -ls -xdev | sort -nrk 7 | head -10
    vidya99343 · 2013-07-22 08:34:28 0
  • 20characters long alpahnumeric "password" Show Sample Output


    -1
    head -c20 /dev/urandom | xxd -ps
    opexxx · 2013-07-16 10:14:21 2
  • perhaps you should use CMD[$2] instead of CMD[$4] Show Sample Output


    0
    history | awk '{CMD[$4]++;count++;} END { for (a in CMD )print CMD[a] " " CMD[a]/count*100 "% " a }' | sort -nr | nl | column -t | head -n 10
    jasee · 2013-07-05 02:38:04 0
  • list the top 15 folders by decreasing size in MB Show Sample Output


    2
    du -xB M --max-depth=2 /var | sort -rn | head -n 15
    bouktin · 2013-05-23 10:45:21 0

  • 1
    awk '{print $1}' ~/.bash_history | sort | uniq -c | sort -rn | head -n 10
    nesses · 2013-05-03 16:24:30 0
  • top 10 of access log


    0
    awk '{ print $9 }' access.log | sort | uniq -c | sort -nr | head -n 10
    cuizhaohua · 2013-05-02 09:23:26 0
  • cut log from line 50 to line 88


    0
    cat -n install.log | head -88 | tac | head -n $(( 88 - 50 )) | tac
    cuizhaohua · 2013-05-02 08:39:54 0
  • cut log from row 100 to row 150.


    0
    cat -n install | head -n 150 | tac | head -n 50 | tac
    cuizhaohua · 2013-05-02 08:11:04 0

  • 0
    awk '/Dec\/2012/ {print $1,$8}' logfile | grep -ivE '(.gif|.jpg|.png|favicon|.css|.js|robots.txt|wp-l|wp-term)' | sort | uniq -c | sort -rn | head -n 20
    vaaclav · 2013-04-30 06:51:47 0
  • Interesting to see which packages are larger than the kernel package. Useful to understand which RPMs might be candidates to remove if drive space is restricted. Show Sample Output


    1
    rpm -qa --queryformat '%{size} %{name}-%{version}-%{release}\n' | sort -k 1,1 -rn | nl | head -16
    mpb · 2013-03-19 21:10:54 0
  • Find top 5 big files


    -3
    find . -type f -exec ls -s {} \; | sort -n -r | head -5
    opexxx · 2013-03-19 12:16:24 1

  • 1
    tr -dc 'A-Za-z0-9!@#$%^&*' < /dev/urandom | fold -w 12 | head -n 1
    opexxx · 2013-03-15 13:20:32 0
  • Replaces hexdump with the more succint xxd, and the sed was unnecessarily complex.


    1
    xxd -p /dev/urandom |fold -60|head -30|sed 's/\(..\)/\1 /g'
    psifertex · 2013-02-19 22:18:52 0
  • or od /dev/urandom -w60 -An|sed 's/ ..../ /g'|head -n 30 (this one lacks digits 8 and 9)


    6
    hexdump -v -e '"%u"' </dev/urandom|fold -60|head -n 30|sed 's/\(.\{2\}\)/\1 /g'
    knoppix5 · 2013-02-16 12:56:24 1

  • 1
    finger `whoami` | awk -F: '{ print $3 }' | head -n1 | sed 's/^ //'
    andrew_duffy · 2013-01-03 20:19:03 3
  • Place in .bash_profile Show Sample Output


    0
    48 function gbl() { git for-each-ref --sort=-committerdate --format='%(committerdate) %(authorname) %(refname)' refs/remotes/origin/|grep -e ".$@"|head -n 10; }
    soheil · 2012-12-13 23:35:06 0
  •  < 1 2 3 4 5 >  Last ›

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: