yfrancis's thinkery

All commands | commandlinefu.com

All commands | commandlinefu.com

command Mar 28, 2011

wget -qO - http://ngrams.googlelabs.com/datasets | grep -E href='(.+\.zip)' | sed -r "s/.*href='(.+\.zip)'.*/\1/" | uniq | while read line; do `wget $line`; done

This is sample output - yours may be different.

/usr/bin/lynx -dump http://www.netins.net/dialup/tools/my_ip.shtml | grep -A2 "Your current IP Address is:" | tail -n1 | tr -d ' '|sed '/^$/d'| sed 's/^ *//g'

This is sample output - yours may be different.

echo -e "Content-type: text/plain\n\n$REMOTE_ADDR"

This is sample output - yours may be different.

mencoder -idx a.ogg -ovc lavc -oac mp3lame -o b.avi

This is sample output - yours may be different.

wget -q -nd http://www.biranchi.com/ip.php; echo "Your external ip is : `cat ip.php`"

This is sample output - yours may be different.

This is a convinient way to do it in scripts. You also want to rm the ip.php file afterwards

grep -o -h -rE '".*"' * | ispell -l -p ~/mydict | sort -u

This is sample output - yours may be different.

echo $(curl -s http://ipwhats.appspot.com/)

This is sample output - yours may be different.

man -t manpage | ps2pdf - filename.pdf

This is sample output - yours may be different.

Quick and dirty version. I made a version that checks if a manpage exists (but it's not a oneliner). You must have ps2pdf and of course Ghostscript installed in your box.

Enhancements appreciated :-)

This is sample output - yours may be different.

7FILESTARTWITHNUMBER
AUTHORS
CODING
COPYING
FAQ
INSTALL
MYTEST1
NEWS
NUM2INBETWEEN
README
TODO

Some source package have many 'README' kind of files, among many other regular files/directories. This command could be useful when one wants to list only 'README' kind of files among jungle of other files. (e.g. I came across this situation after downloading source for module-init-tools)

Warning: This command would miss a file like => README.1 (or one with spaces in-between)

Corrections welcome.

apt-get -y install git-core gitosis; adduser --home /home/git --gecos "git user" git; su git -c "ssh-keygen -t rsa -f /home/git/.ssh/id_rsa; gitosis-init < ~/.ssh/id_rsa"

This is sample output - yours may be different.

After, check if working by executing this command locally :

git clone git@192.168.0.18:repositories/gitosis-admin.git

Tutorial :

http://blog.hemca.com/?p=560

This is sample output - yours may be different.

This is sample output - yours may be different.

grep -i -f password_tokens sslstrip.log | awk ' BEGIN { RS="&" } { print $1 }' | grep -i -f tokens_file

This is sample output - yours may be different.

rename 's/\.txt$/\.md$/i' *

This is sample output - yours may be different.

cd $srcdir && find -type d -exec mkdir -p $dstdir/{} \;

This is sample output - yours may be different.

Clone directory structure without the files

rm -rf !(@(file1|file2|...))

This is sample output - yours may be different.

This is sample output - yours may be different.

This is sample output - yours may be different.

tar -czvf - /src/dir | ssh remotehost "(cd /dst/dir ; tar -xzvf -)"

This is sample output - yours may be different.

This is sample output - yours may be different.

shopt -s nullglob; for i in $(find "Your/file/system" -name "*.pdf"); do e="$(dirname $i)/$(basename $i '.pdf').png"; gs -sDEVICE=png16m -q -dPDFFitPage -g492x380 -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -dNOSUBSTDEVICECOLORS -o $e $i; done

This is sample output - yours may be different.

Using ghostscript instead of imagemagick to convert pdfs into pngs. It keeps pngs with pdfs

awk '/^'$SEARCH'[ ]*$/{getline;if ($1 ~ /query/) {split($4,a,".");print a[2]}}' /etc/sybase/interfaces

This is sample output - yours may be different.

Awk magic to replace:

cat /etc/sybase/interfaces | grep -A 1 -e "$SEARCH" | grep query | awk '{ print $4 }' | awk -F'.' '{print $2}'

This is sample output - yours may be different.

$ python3.1 -m http.server
Serving HTTP on 0.0.0.0 port 8000 ...

In Python version 3, the module was merged into http.server. Gentlemen, change your aliases.

hexdump -e '8/1 "%02X ""\t"" "' -e '8/1 "%c""\n"' /dev/sda1 | less /mystring

This is sample output - yours may be different.

gcal -i -s1 -qcn --chinese-months -cezk .

This is sample output - yours may be different.

                                2010/2011


      November                  December                  January
 Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su
  1  2  3  4  5  6  7             1  2  3  4  5                    : 1: 2:
  8  9 10 11 12 13 14       6  7  8  9 10 11 12       3  4  5  6  7  8  9
 15 16 17 18 19 20 21      13 14 15 16<17>18 19      10 11 12 13 14 15 16
 22 23 24 25 26 27 28      20 21 22 23 24 25 26      17 18 19 20 21 22 23
 29 30                     27 28 29 30 31            24 25 26 27 28 29 30
                                                     31                  

Fixed date list:

1)  |44|   Sa,   6 Nov 2010: Start of common month 10/4647 (Chi*)
2)  |49|   Mo,   6 Dec 2010: Start of common month 11/4647 (Chi*)
3)  |51|   We,  22 Dec 2010: Solstice Day (CN)
4)  |52/0| Sa, : 1:Jan 2011: New Year's Day (CN)
5)  |52/0| Su, : 2:Jan 2011: New Year's Day (CN)
6)  |01|   Tu,   4 Jan 2011: Start of common month 12/4647 (Chi*)

包括: 除夕(Chinese New Year?s Day)、清明(Tomb-Sweeping Day)、端午(Dragon Boat Festival)、中秋(Mid-Autumn Festival)等传统节日,以及元旦、五一、十一、儿童节、教师节等。