alias lst="ls -ls -tr | tail" Show Sample Output
The AWK part of the code will "collate" the fields from 2nd to Nth field (this is to handle any svn directories that may have spaces in them - typical when working with code that is interchangeably used with windows environment - for example, documentation teams) - the output is passed to "ls -ld" - the -d option to ls will tell ls to handle directories itself, rather than do ls on the directory. The '-p' option is just for pretty printing directories, links and executables (for added readability). Finally, the entire "constructed" command will be passed onto sh for shell execution. Show Sample Output
Some Unix systems have this by default. Check if you need to add it on yours. Show Sample Output
Returns a list, with attributes (think `ls -l`), in reverse chronological order. N is a single numeric parameter. Robust against unfriendly filenames and directory structures. Show Sample Output
I've shortened it to:
lsc PATH | l
... by adding ...
alias lsc="ls --color"
... and ...
alias l="less -R"
... to my ~/.bashrc file
It will print a compact ls -la list with the directories at the beginning.
--almost-all - do not list implied . and ..
--group-directories-first - group directories before files
--color - colorize the output
--no-group - in a long listing, don't print group names
--human-readable - print human readable sizes (e.g., 1K 234M 2G)
--classify - append indicator (one of */=>@|) to entries
If you want to see the owner:
ls -l --almost-all --group-directories-first --color --no-group --human-readable --classify
Show Sample Output
I seem to do this compulsively every time I change directories, sometimes even when I don't, even if I know exactly what I need to do. (Don't worry, the sample output is just an exaggeration. :) Show Sample Output
There's no need for ls or grep; printf is builtin to most modern shells
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
Opens the current working directory in the user's preferred application using freedesktop.org's xdg-open.
This will show you the permissions on the directory you are currently in
nothing fancy `ls` alternative `exa`, with most info printed and passed through less with the `-R` (raw) option, to preserve colour output https://github.com/ogham/exa You can add or remove `-@` to print extended attributes for files that have them. Show Sample Output
If you put this in your .bashrc, you might also want to add this to make it use the colors by default:
alias ls="ls --color=auto"
I have a directory containing log files. This command delete all but the 5 latest logs. Here is how it works: * The ls -t command list all files with the latest ones at the top * The awk's expression means: for those lines greater than 5, delete.
trying to copy all your dotfiles from one location to another, this may help Show Sample Output
This is useful for paging through long directories, mulitple directories, etc. I put this in my ~/.bash_aliases file and alias 'lsl' to it.
For this example, all files in the current directory that end in '.xml.skippy' will have the '.skippy' removed from their names.
Here's a version that doesn't use find.
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)
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: