I'm trying to find a command that would list all files (including hidden files), but must exclude the current directory and parent directory. Please help.
$ ls -a \.\..
Use the ls command to display the contents of a directory. The ls command writes to standard output the contents of each specified Directory or the name of each specified File, along with any other information you ask for with the flags.
Open the command-line shell and write the 'ls” command to list only directories. The output will show only the directories but not the files. To show the list of all files and folders in a Linux system, try the “ls” command along with the flag '-a” as shown below.
To list all files and sort them by size, use the -S option. By default, it displays output in descending order (biggest to smallest in size). You can output the file sizes in human-readable format by adding the -h option as shown. And to sort in reverse order, add the -r flag as follows.
The "ls" command has many options that, when passed, affect the output. For example, the "-a" option will show all files and folders, including hidden ones.
Regarding the ls(1) documentation (man ls
):
-A, --almost-all do not list implied . and ..
you need (without any additional argument such as .*
):
ls -A
or better yet:
/bin/ls -A
$ ls -lA
works best for my needs.
For convenience I recommend to define an alias within .bashrc-file as follows:
alias ll='ls -lA'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With