The command gives size of all files smaller than 1024k, this information, together with disk usage, can help determin file system parameter (e.g. block size) or storage device (e.g. SSD v.s. HDD). Note if you use awk instead of "cut| dc", you easily breach maximum allowed number of records in awk. Show Sample Output
Simple file browser with dmenu, ls, and xdg-open.
ls -Q will show the filenames in quotes. xargs -p rm will print all the filenames piped from ls -Q and ask for confirmation before deleting the files. without the -Q switch, if we have spaces in names, then the files won't be deleted. Show Sample Output
rm-but() { ls -Q | grep -v "$1" | xargs rm -r ; }
Add this to your .bashrc file.
Then whenever you need to remove all files/directories but one from present working directory. Run:
rm-but <important-file-or-directory>
Notes:
1. This doesn't affect the hidden files.
2. Argument is actually as string. And all files/directories having this string in there name are left untouched.
the command will calculate the size of hidden files Show Sample Output
This version eliminates the grep before the awk, which is always good. It works for GNU core utils and ensures that the date output of ls matches the format in the pattern match, regardless of locale, etc. On BSD-based systems, you can easily eliminate both the grep and the awk: find . -maxdepth 1 -Btime -$(date +%kh%lm) -type f
I've been looking for a way to do this for a while, get a not pattern for shell globs. This works, I'm using to grab logs from a remote server via scp. Show Sample Output
I'm not sure why you would want to do this, but this seems a lot simpler (easier to understand) than the version someone submitted using awk.
Use it for command like : mkdir, chown, ls, less...
reverse the sorting of ls to get the newest file:
ls -1tr --group-directories-first /path/to/dir/ | tail -n 1
Problems:
If there are no files in the directory you will get a directory or nothing.
It disturbs me when my logwatch report tells me a share or machine has disappeared, esp as mount isn't telling me what's gone. This command outputs to stderr the erroring cifs entries from fstab. Show Sample Output
A shorter version Show Sample Output
Center the output text in max line length of buffered output pipe; Show Sample Output
The output will likely point to '/etc/alternatives/java'. So find out where that points by issuing ls -l like this: ls -l /etc/alternatives/java
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 bash-3.2$ hitlar filename Show Sample Output
omit the 1 (one) if you don't need one-per-line
This is a equivalent to the GNU ' readlink' tool, but it supports following all the links, even in different directories.
An interesting alternative is this one, that gets the path of the destination file
myreadlink() { [ ! -h "$1" ] && echo "$1" || (local link="$(expr "$(command ls -ld -- "$1")" : '.*-> \(.*\)$')"; cd $(dirname $1); myreadlink "$link" | sed "s|^\([^/].*\)\$|$(dirname $1)/\1|"); }
Show Sample Output
It's both silly, and infinitely useful. Especially useful in logfile directories where you want to know what file is being updated while troubleshooting.
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.
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.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
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: