
Terminal - Commands using head - 194 results
pronounce(){ wget -qO- $(wget -qO- "http://dictionary.reference.com/browse/$@" | grep 'soundUrl' | head -n 1 | sed 's|.*soundUrl=\([^&]*\)&.*|\1|' | sed 's/%3A/:/g;s/%2F/\//g') | mpg123 -; }
This is sample output - yours may be different.
This one uses dictionary.com
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.
git log -g --pretty=oneline | grep '}: commit' | awk '{print $1}' | head -1 | xargs git checkout -f
This is sample output - yours may be different.
TOTAL_RAM=`free | head -n 2 | tail -n 1 | awk '{ print $2 }'`; PROC_RSS=`ps axo rss,comm | grep [h]ttpd | awk '{ TOTAL += $1 } END { print TOTAL }'`; PROC_PCT=`echo "scale=4; ( $PROC_RSS/$TOTAL_RAM ) * 100" | bc`; echo "RAM Used by HTTP: $PROC_PCT%"
This is sample output - yours may be different.
RAM Used By HTTP: 50.5000%
Change the name of the process and what is echoed to suit your needs. The brackets around the h in the grep statement cause grep to skip over "grep httpd", it is the equivalent of grep -v grep although more elegant.
newest () { DIR=${1:-'.'}; CANDIDATE=`find $DIR -type f|head -n1`; while [[ ! -z $CANDIDATE ]]; do BEST=$CANDIDATE; CANDIDATE=`find $DIR -newer "$BEST" -type f|head -n1`; done; echo "$BEST"; }
This is sample output - yours may be different.
[user@localhost ~]$ newest /var/www/html/
/var/www/html/manual/createCustomColumn.png
[user@localhost ~]$
Works recusivley in the specified dir or '.' if none given.
Repeatedly calls 'find' to find a newer file, when no newer files exist you have the newest.
In this case 'newest' means most recently modified. To find the most recently created change -newer to -cnewer.
du -s * | sort -nr | head | cut -f2 | parallel -k du -sh
This is sample output - yours may be different.
33M a b
17M libxnee
3.6M doc
3.0M gnee
If a directory name contains space xargs will do the wrong thing. Parallel https://savannah.nongnu.org/projects/parallel/ deals better with that.
paste -d "." <(curl http://.../dist.female.first http://.../dist.male.first | cut -d " " -f 1 | sort -uR) <(curl http://..../dist.all.last | cut -d " " -f 1 | sort -R | head -5163) | tr "[:upper:]" "[:lower:]" | sed 's/$/@test.domain/g'
This is sample output - yours may be different.
stasia.palmer@test.domain
mozell.sybounheuan@test.domain
yuki.nypaver@test.domain
annamae.tilbury@test.domain
jaimee.warfield@test.domain
cassidy.mchugh@test.domain
daniele.makey@test.domain
ivelisse.besancon@test.domain
marylin.kocher@test.domain
ifconfig | grep -B 1 "inet addr:" | head -1 | cut -d" " -f1
This is sample output - yours may be different.
Get the line containing "inet addr:" and the line before that, get down to only the first line, and then get the first word on that line, which should be the interface.
tr -dc 'a-zA-Z0-9' < /dev/urandom | head -c10
This is sample output - yours may be different.
A slightly shorter version. Also doesn't put a return character at the end of the password
cat *.c | { printf "se te du\nplot '-' t '' w dots\n"; tr '[[:upper:]]' '[[:lower:]]' | tr -s [[:punct:][:space:]] '\n' | sort | uniq -c | sort -nr | head -n 100 | awk '{print $1}END{print "e"}'; } | gnuplot
This is sample output - yours may be different.
$ cat *.c | { printf "se te du\nplot '-' t '' w dots\n"; tr '[[:upper:]]' '[[:lower:]]' | tr -s [[:punct:][:space:]] '\n' | sort | uniq -c | sort -nr | head -n 100 | awk '{print $1}END{print "e"}'; } | gnuplot
60 .+-----+------+------+------+-------+------+------+------+------+-----++
+ + + + + + + + + + +
| |
50 ++ ++
| |
|. |
|. |
40 ++ ++
| |
| .. |
30 ++ ++
| . |
| |
20 ++ .. ++
| .. |
| .. |
| ... |
10 ++ .... ++
| ............... |
+ + + + + .......................................+
0 ++-----+------+------+------+-------+------+------+------+------+-----++
0 10 20 30 40 50 60 70 80 90 100
Uses the dumb terminal option in gnuplot to plot a graph of frequencies. In this case, we are looking at a frequency analysis of words in all of the .c files.
mkpasswd() { head -c $(($1)) /dev/urandom | uuencode - | sed -n 's/.//;2s/\(.\{'$1'\}\).*/\1/p' ;}
This is sample output - yours may be different.
$ mkpasswd 56
AB:C[)\"=H#J:E()EY>HA6J,R741+ACL&08PC)P4Z#3R^YZ*3L0@O<<6
$ mkpasswd 9
YMO;<&.FB
This uses urandom to produce a random password. The random values are uuencoded to ensure only printable characters. This only works for a number of characters between 1 and 60.
for i in *.avi; do echo -n "$i:";mediainfo $i|head | grep PlayTime | cut -d: -f2 ; done | sort -t: -k2 -r
This is sample output - yours may be different.
Similar but using mediainfo instead of totem-something
ps -eo pcpu,user,pid,cmd | sort -r | head -5
This is sample output - yours may be different.
shuf -i 1-49 | head -n6 | sort -n| xargs
This is sample output - yours may be different.
note the xargs at the end
echo $(shuf -i 1-49 | head -n6 | sort -n)
This is sample output - yours may be different.
for f in *.html; do head -n -1 $f > temp; cat temp > $f; rm temp; done
This is sample output - yours may be different.
Some malicious program appends a iframe or script tag to you web pages on some server, use this command to clean them in batch.
head -c10 <(echo $RANDOM$RANDOM$RANDOM)
This is sample output - yours may be different.
Makes use of $RANDOM environment variable.
tr -c -d 0-9 < /dev/urandom | head -c 10
This is sample output - yours may be different.
head -c4 /dev/urandom | od -N4 -tu4 | sed -ne '1s/.* //p'
This is sample output - yours may be different.
find ~/Music -daystart -mtime -60 -name *mp3 -printf "%T@\t%p\n" | sort -f -r | head -n 30 | cut -f 2
This is sample output - yours may be different.
awk '{print $1}' /var/log/httpd/access_log | sort | uniq -c | sort -rnk1 | head -n 10
This is sample output - yours may be different.
for x in `seq 0 25 $(curl "http://www.commandlinefu.com/commands/browse"|grep "Terminal - All commands" |perl -pe 's/.+(\d+),(\d+).+/$1$2/'|head -n1)`; do curl "http://www.commandlinefu.com/commands/browse/sort-by-votes/plaintext/$x" ; done > a.txt
This is sample output - yours may be different.
'jot' does not come with most *nix distros, so we need to use seq to make it work. This version tested good on Fedora 11.
for x in `jot - 0 \`curl "http://www.commandlinefu.com/commands/browse"|grep "Terminal - All commands" |perl -pe 's/.+(\d+),(\d+).+/$1$2/'|head -n1\` 25`; do curl "http://www.commandlinefu.com/commands/browse/sort-by-votes/plaintext/$x" ; done >a.txt
This is sample output - yours may be different.
# SSH connection through host in the middle
ssh -t reachable_host ssh unreachable_host
# A fun thing to do with ram is actually open it up and take a peek. This command will show you all the string (plain text) values in ram
sudo dd if=/dev/mem | cat | strings
# Watch Star Wars via telnet
telnet towel.blinkenlights.nl
# Backticks are evil
echo "The date is: $(date +%D)"
This is an extension of a previous command by satyavvd on 2009-07-23 12:04:02, but this one grabs the whole archive. Hard coded numbers in previous script capped number of commands that could be fetched. This one grabs them all regardless of how big the archive gets.
find / -type f -exec wc -c {} \; | sort -nr | head -100
This is sample output - yours may be different.
mysql -u<user> -p<password> -s -e 'DESCRIBE <table>' <database> | tail -n +1 | awk '{ printf($1",")}' | head -c -1
This is sample output - yours may be different.