commandlinefu.com is the place to record those command-line gems that you return to again and again.
Delete that bloated snippets file you've been using and share your personal repository with the world. 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.
You can sign-in using OpenID credentials, or register a traditional username and password.
First-time OpenID users will be automatically assigned a username which can be changed after signing in.
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.
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:
Wow, didn't really expect you to read this far down. The latest iteration of the site is in open beta. It's a gentle open beta-- not in prime-time just yet. It's being hosted over at UpGuard (link) and you are more than welcome to give it a shot. Couple things:
List all files in a directory in reverse order by modified timestamp. When piped through tail the user will see the most recent file name.
Tells you everything you could ever want to know about all files and subdirectories. Great for package creators. Totally secure too.
On my Slackware box, this gets set upon login:
LS_OPTIONS='-F -b -T 0 --color=auto'
alias ls='/bin/ls $LS_OPTIONS'
which works great.
ls -F | grep /\$
but will break on directories containing newlines. Or the safe, POSIX sh way (but will miss dotfiles):
for i in *; do test -d "./$i" && printf "%s\n" "$i"; done
Normally, if you just want to see directories you'd use brianmuckian's command 'ls -d *\', but I ran into problems trying to use that command in my script because there are often multiple directories per line. If you need to script something with directories and want to guarantee that there is only one entry per line, this is the fastest way i know
Was playing with the shell. It struck to me, just by rearranging the parameters, i was able to remember what they did and in a cool way.
Enter the 'hitlar' mode.
bash-3.2$ ls -hitlar
Shows all items with inodes, in list view, human readable size, sorted by modification time in reverse,
bash-3.2$ ls -Fhitlar
Shows the same with classification info. Add the hitlar mode alias to your .bashrc.
bash-3.2$ echo "alias hitlar='ls -Fhitlar'" >> ~/.bashrc
bash-3.2$ hitlar filename
... plus do a sort according frequency
A shorter version
Works on current directory, with built-in sorting.
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)
Opens the current working directory in the user's preferred application using freedesktop.org's xdg-open.
when working under a cli sometime you need to list the files with ls
but u can open gnome file browser with the command 'gnome-open .' under current directory
To monitor .vmdk files during snapshot deletion (commit) on ESX only (ESXi doesn't have the watch command):
1. Navigate to the VM directory containing .vmdk files.
# watch "ls -tough --full-time *.vmdk"
-t sorts by modification time
-o do not list group information (to narrow the output)
-u sorts by access time
-g only here for the purpose to easily remember the created mnemonic word 'tough'
-h prints sizes in human readable format (e.g., 1K 234M 2G)
--full-time sets the time style to full-iso and does not list user information (to narrow the output)
optionally useful parameters to the watch command:
-d highlight changes between updates
-n seconds to wait between updates (default is 2)
-t turn off printing the header
Great idea camocrazed. Another twist would be to display a different man page based on the day of the year. The following will continuously cycle through all man pages:
man $(ls /bin | sed -n $(($(date +%j) % $(ls /bin | wc -l)))p)
Tested and works on Linux.
Looks like you're stuck with sed if your ls doesn't have a -Q option.
If we want files with more than one extension, like .tar.gz, only appear the latest, .gz:
ls -Xp /path/to/dir | grep -Eo "\.[^./]+$" | uniq
You may also use the $(which foo) variant instead of backticks. I personnaly have an alias ll='ls -l'.
Please be careful while executing the following command as you don?t want
to delete the files by mistake. The best practice is to execute the same
command with ls ?l to make sure you know which files will get deleted when
you execute the command with rm.
This shows every bit of information that stat can get for any file, dir, fifo, etc. It's great because it also shows the format and explains it for each format option.
If you just want stat help, create this handy alias 'stath' to display all format options with explanations.
alias stath="stat --h|sed '/Th/,/NO/!d;/%/!d'"
To display on 2 lines:
( F=/etc/screenrc N=c IFS=$'\n'; for L in $(sed 's/%Z./%Z\n/'<<<`stat --h|sed -n '/^ *%/s/^ *%\(.\).*$/\1:%\1/p'`); do G=$(echo "stat -$N '$L' \"$F\""); eval $G; N=fc;done; )
For a similarly powerful stat-like function optimized for pretty output (and can sort by any field), check out the "lll" function
From my .bash_profile ->