### Commands by dinomite (6) the last day the last week the last month all time sorted by date votes

• Grabs the complete module list from CPAN, pulls the first column, ditches html lines, counts, ditches small namespaces.

1
curl http://www.cpan.org/modules/01modules.index.html |awk '{print $1}'|grep -v "<"|sort|uniq -c|grep -v " +[0-9] " · 2011-10-18 16:03:54 • If you want to turn a Git repo into the origin that folks can push to, you should make it a bare repository. See: http://stackoverflow.com/questions/2199897/git-convert-normal-to-bare-repository 1 mv .git .. && rm -rf * && mv ../.git . && mv .git/* . && rmdir .git && git config --bool core.bare true · 2011-02-28 17:58:14 • If you want to pull all of the files from a tree that has mixed files and directories containing files, this will link them all into a single directory. Beware of filesystem files-per-directory limits. 2 find /deep/tree/ -type f -print0|xargs -0 -n1 -I{} ln -s '{}' . · 2010-12-21 13:00:33 • Get just the IP address for a given hostname. For best results, make this a function in your shell rc file so that it can be used for things like traceroute: Titus:~$ traceroute getip foo.com traceroute to 64.94.125.138 (64.94.125.138), 64 hops max, 52 byte packets Show Sample Output

-1
host foo.com|grep " has address "|cut -d" " -f4
· 2010-10-29 17:01:37
• Create a tar file in multiple parts if it's to large for a single disk, your filesystem, etc. Rejoin later with cat .tar.*|tar xf - Show Sample Output

17
tar cf - <dir>|split -b<max_size>M - <name>.tar.
· 2009-11-11 01:53:33
• Get your colorized grep output in less(1). This involves two things: forcing grep to output colors even though it's not going to a terminal and telling less to handle those properly.

32
grep --color=always | less -R
· 2009-05-20 20:30:19

### 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.

### Check These Out

Make changes in .bashrc immediately available
You may want to just use the shortcut "." instead of "source"

Rename all files which contain the sub-string 'foo', replacing it with 'bar'
Would this command line achieve the desired function? My CLI knowledge is not great so this could certainly be wrong. It is merely a suggestion for more experienced uses to critique. Best wishes roly :-)

Commandline document conversion with Libreoffice
In this example, the docx gets converted to Open Document .odt format. For other formats, you'll need to specify the correct filter (Hint: see "Comments" link below for a nice list).

Colorizes an access log
Puts a splash of color in your access logs. IP addresses are gray, 200 and 304 are green, all 4xx errors are red. Works well with e.g. "colorize access_log | less -R" if you want to see your colors while paging. Use as inspiration for other things you might be tailing, like syslog or vmstat Usage: $tail -f access.log | colorize edit, view or execute last modified file with a single key-press Copy this function to command line, press 'Enter' 'f'' 'Enter' to execute (sentence on the left written only for newbies). Hint 'e|x|v|1..9' in front of displayed last modified file name means: "Press 'e' for edit,'x' for execute,'v' for view or a digit-key '1..9' to touch one file from the recent files list to be last modified" and suggested (hidden files are listed too, else remove 'a' from 'ls -tarp' statement if not intended). If you find this function useful you can then rename it if needed and append or include into your ~/.bashrc config script. With the command$ . ~/.bashrc the function then can be made immediately available. In the body of the function modifications can be made, i.e. replaced joe editor command or added new option into case statement, for example 'o) exo-open $h;;' command for opening file with default application - or something else (here could not be added since the function would exceed 255 chars). To cancel execution of function started is no need to press Ctrl-C - if the mind changed and want to leave simple Enter-press is enough. Once defined, this function can with$ typeset -f f command be displayed in easy readable form

Search some text from all files inside a directory

Which processes are listening on a specific port (e.g. port 80)
swap out "80" for your port of interest. Can use port number or named ports e.g. "http"

escape any command aliases
e.g. if rm is aliased for 'rm -i', you can escape the alias by prepending a backslash: rm [file] # WILL prompt for confirmation per the alias \rm [file] # will NOT prompt for confirmation per the default behavior of the command

Find removed files still in use via /proc
Oracle DBA remove some logfiles which are still open by the database and he is complaining the space has not been reclaimed? Use the above command to find out what PID needs to be stopped. Or alternatively recover the file via: $cp /proc/pid/fd/filehandle /new/file.txt Quickly generate an MD5 hash for a text string using OpenSSL Thanks to OpenSSL, you can quickly and easily generate MD5 hashes for your passwords. Alternative (thanks to linuxrawkstar and atoponce):$ echo -n 'text to be encrypted' | md5sum - Note that the above method does not utlise OpenSSL.