commandlinefu.com is the place to record those command-line gems that you return to again and again.
You can sign-in using OpenID credentials, or register a traditional username and password.
Subscribe to the feed for:
Creates a PDF (over ps as intermediate format) out of any given manpage.
Other useful arguments for the -T switch are dvi, utf8 or latin1.
When a fs hangs and you've just one console, even # ls could be a dangerous command. Simply put a trailing "&" and play safe
order the files by modification (thanks stanishjohnd) time, one file per output line and filter first 10
You can convert any UNIX man page to .txt
Sort ls output of all files in current directory in ascending order
Just the 20 biggest ones:
ls -la | sort -k 5bn | tail -n 20
A variant for the current directory tree with subdirectories and pretty columns is:
find . -type f -print0 | xargs -0 ls -la | sort -k 5bn | column -t
And finding the subdirectories consuming the most space with displayed block size 1k:
du -sk ./* | sort -k 1bn | column -t
The URL can then be pasted with a middle click.
This is probably useful when trying to explain problems over instant messaging when you don't have some sort of shared desktop.
added alias in ~/.bashrc
alias lf='find ./* -ctime -1 | xargs ls -ltr --color'
To sort hidden files first, simply switch the two inner `ls` commands.
I have this aliased to `dira`
`dir` is aliased to the simpler version with no hidden files:
ls -l --color=always | less -R
This works on my ubuntu/debian machines.
I suspect other distros need some tweaking of sort and cut.
I am sure someone could provide a shorter/faster version.
Yeah, there are many ways to do that.
Doing with sed by using a for loop is my favourite, because these are two basic things in all *nix environments. Sed by default does not allow to save the output in the same files so we'll use mv to do that in batch along with the sed.
Ok so it's rellay useless line and I sorry for that, furthermore that's nothing optimized at all...
At the beginning I didn't managed by using netstat -p to print out which process was handling that open port 4444, I realize at the end I was not root and security restrictions applied ;p
It's nevertheless a (good ?) way to see how ps(tree) works, as it acts exactly the same way by reading in /proc
So for a specific port, this line returns the calling command line of every thread that handle the associated socket
A powerfull way to rename file using sed groups.
& stand for the matched expression.
\1 referes to the first group between parenthesis. \2 to the second.
This command list and sort files by size and in reverse order, the reverse order is very helpful when you have a very long list and wish to have the biggest files at the bottom so you don't have scrool up.
The file size info is in human readable output, so ex. 1K..234M...3G
Tested with Linux (Red Hat Enterprise Edition)
64 elements max on 16 rows, 4 cols.
GNU Barcode will adapt automagically the width and the eight of your elements to fill the page.
Standard output format is PostScript.
Suppose that you had change in a directory like /home/user/mycode/code, and now you need to list it, instead of type entire path again, use ls !$ to recall path and list. Useful with many commands, this is only an example. (In this case, same result can be achivied with ls .)
Shows all linked file and destinations. The 'ls -l' command lists the files in long (1 file per line) format, and the grep command displays only those lines that starts with an l (lower case L) -- a linked file.
Updated: Remove reference to hard links because this command does not apply to hard link as others kindly pointed out.
List files above a given size threshold.
head by default displays first ten lines of its output. Use 'head -nXX' to display the XX largest files
Finds all files of a certain name and reports all line with the string. Very simple.
Coming back to a project directory after sometime elsewhere?
Need to know what the most recently modified files are?
This little function "t" is one of my most frequent commands.
I have a tcsh alias for it also:
alias t 'ls -ltch \!* | head -20'
Allows for quick mass renaming, assuming the user has some familiarity with regular expressions. Basically, it replaces the original_file_name in the output of ls with
"mv -v original_file_name new_file_name"
and passes the output to sh.