How do I delete all files that start with 'labtest,' but keep the file 'labtest' itself undeleted?
I was trying
rm labtest*[!"labtest"]
But that didn't work out too well.
Question 5
Enter a command to delete all files that have filenames starting with 'labtest',
except 'labtest' itself, from the current directory (Delete all files starting
with 'labtest' followed by one or more characters).
You entered: rm *labtest?![labtest]
Please try again.
This will delete all files in the current directory starting with labtest
except for the file labtest
itself. It will not consider files unless they begin with labtest
echo labtest?* # List files that begin with "labtest"
rm labtest?* # Delete them
The question-mark is a single character wildcard: it must match something. The asterisk is a globbing wildcard and will match zero or more characters. The combination ensures that we cannot match just labtest
by itself.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments