I am in need of deleting all executable
files from a directory. My directory contains some configuration files and executable files, and I need to delete all executable
files that I don't want.
For that I have wrote a command like this:
ls -lp | grep -v / | awk 'match($0,"-**x*x*x",a);{print a[1]}'| \
awk '{print $9}' | xargs rm -f
Is there aother way to do this?
I tried with find
. It will list all other sub directory files. I used grep -v /
, to avoid sub-directories in the current folder.
Best Answer
You should use
find
for this task:will show you the files that are executable by current user, recursively.
To limit the search to current directory only:
To remove:
Or with GNU
find
:As a side note, if you want to find files executable by any user, not just the current user (set as regular execute permission bits):