I have a folder with the following files / folders:
.test
README.md
/dist
/src
I want to grep all files beside dist
. So the result should look like:
.test
README.md
/src
When I do
ls -a | grep -v dist
it will remove dist. But .
and ..
are present. However I require the -a
to get files with dot prefix.
When I try to add ls -a | grep -v -e dist -e . -e ..
there is no output.
Why will -e .
remove all files? How to do it?
CodePudding user response:
Better to use find
with -not
option instead of error prone ls | grep
:
find . -maxdepth 1 -mindepth 1 -not -name dist
btw just for resolving your attempt, correct ls | grep
would be:
ls -a | grep -Ev '^(dist|\.\.?)$'
CodePudding user response:
If you use bash, you can do :
shopt -s extglob
echo .[^.]* !(dist)