Views:
2,275ā
Votes: 3ā
ā
Solution
Tags:
command-line
ls
hidden-files
Link:
š See Original Answer on Ask Ubuntu ā§ š
URL:
https://askubuntu.com/q/1244495
Title:
How can I exclude . and .. when listing hidden items?
ID:
/2020/05/28/How-can-I-exclude-.-and-/How-can-I-exclude-.-and-..-when-listing-hidden-items_
Created:
May 28, 2020
Edited: May 28, 2020
Upload:
September 15, 2024
Layout: post
TOC:
false
Navigation: false
Copy to clipboard: false
From the second answer in:
This works on my machine (Iām not using SSH like the OP though):
ls -d .!(|.)
If there are no hidden files or directories you will get an error message:
$ ls -d .!(|.)
ls: cannot access '.!(|.)': No such file or directory
The error message occurs on directories with no hidden files because .
and ..
are excluded.
shopt
consideration
From comments:
ls -d .[!.]*
works without extglob