Esc-/ Esc-/

List files

Shortcut to list files in the current path.

5
By: strzel_a
2010-11-17 23:24:11

These Might Interest You

  • I find it very handy to be able to quickly see the most recently modified/created files in a directory. Note that the "q" option will reveal any files with non-printable characters in their filename. Show Sample Output


    7
    ls -qaltr # list directory in chronological order, most recent files at end of list
    mpb · 2013-02-25 14:14:44 1
  • A quick find command to identify all TAR files in a given path, extract a list of files contained within the tar, then search for a given string in the filelist. Returns to the user as a list of TAR files found (enclosed in []) followed by any matching files that exist in that archive. TAR can easily be swapped for JAR if required. Show Sample Output


    1
    find . -type f -name "*.tar" -printf [%f]\\n -exec tar -tf {} \; | grep -iE "[\[]|<filename>"
    andrewtayloruk · 2011-01-06 13:01:38 0
  • This Command will list files & folders which are in GBs. G can be replace by M to get files in MBs.


    0
    du -h |grep -P "^\S*G"
    girish_patel · 2010-12-13 15:26:31 0
  • Take a folder full of files and split it into smaller folders containing a maximum number of files. In this case, 100 files per directory. find creates the list of files xargs breaks up the list into groups of 100 for each group, create a directory and copy in the files Note: This command won't work if there is whitespace in the filenames (but then again, neither do the alternative commands :-)


    -1
    files -type f | xargs -n100 | while read l; do mkdir $((++f)); cp $l $f; done
    flatcap · 2011-02-15 23:15:16 1
  • I find it useful, when cleaning up deleting unwanted files to make more space, to list in size order so I can delete the largest first. Note that using "q" shows files with non-printing characters in name. In this sample output (above), I found two copies of the same iso file both of which are immediate "delete candidates" for me. Show Sample Output


    1
    ls -qahlSr # list all files in size order - largest last
    mpb · 2013-03-13 09:52:07 0
  • 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) Corrections welcome. Show Sample Output


    0
    ls | grep '^[A-Z0-9]*$'
    b_t · 2010-12-19 21:45:53 1

What Others Think

That was nice. Just wondering if there is a way to further customize this - like adding switches to ls (e.g. ls -laF)
b_t · 391 weeks and 6 days ago
Add the following lines to your .inputrc: "\el": "ls\n" "\eL": "ls -lh\n" With this, alt-l or esc-l will list current files, and L will do ls -lh. You can mess around with this to do all kinds of fun things (like having a keybinding for sshing to a particular machine, or just pasting some boilerplate text in).
royalawesome · 391 weeks and 2 days ago
Tab Tab gives me the same list...
slu · 391 weeks and 1 day ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

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.

Share Your Commands



Stay in the loop…

Follow the Tweets.

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

Subscribe to the feeds.

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: