| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
ls /directory | grep mystringor
rm $(ls | grep -v '\.c$')# BASH
shopt -s extglob
rm -- !(*.c)
# POSIX
for f in ./*
do
case $f in
*.c) true;;
*) rm "$f";;
esac
doneParsing ls is generally a bad idea because the output is fragile and human readable. To better handle non-alphanumeric filenames, use a glob. If you need more advanced matching than a glob can provide, use a for loop.
| Back | FazBrowse Home | New Git URL |