I saw in your( @thinksinbinary ) comment on the answer by @thomasrutter , that you wanted to be able to print them in reverse order and in columns. You probably have already figured it out or moved on, but here it is:
ls -pr | grep -v / | column
-p adds the forward slash ('/') to the directory names
-r reverses the order of output
-v lets grep do an inverse search to print everything except the directories (everything that doesn't have the '/' that -p put there)
Using
ls -p
tellsls
to append a slash to entries which are a directory, and usinggrep -v /
tellsgrep
to return only lines not containing a slash.You may try this:
find . -maxdepth 1 -not -type d
And map this to a special alias.
But if you're really keen on using the
ls
command, here:ls -p | egrep -v /$
Alternatively:
This method lists in
-l
Long list format-A
Displays almost all (show hidden files but don't show.
and..
)-h
Human readable file sizeswhile grep
-v
Don't show matching recordsRegular expression
filter^d
- Those start with letter d (for directory) i.edrwxrwxr-x <some file details> <foldername>
If you don't want to type every time, you may make it into an alias for your bash/shell profile.
I saw in your( @thinksinbinary ) comment on the answer by @thomasrutter , that you wanted to be able to print them in reverse order and in columns. You probably have already figured it out or moved on, but here it is:
If you want only files and don't want to perform any operation on them, then run:
Or, if you want to iterate on each file, then for me this works:
Above command displays files, But it includes symlinks, pipes, etc. If you want to eliminate them too, you can use one of the flags mentioned below.
ls -F
appends symbols to filenames. These symbols show useful information about files.@
means symbolic link (or that the file has extended attributes).*
means executable.=
means socket.|
means named pipe.>
means door./
means directory.Above command displays only files.
You might want to use
du
instead ofls
. It will only output files. Then justawk '{print $2}'
to output only the file path.You have to use the -d option with du to limit depth. http://linuxcommand.org/lc3_man_pages/du1.html
What if you only want folders, only files or both?
What if you want hidden files or hidden folders or not?