swcarpentry / shell-novice

The Unix Shell
http://swcarpentry.github.io/shell-novice/
Other
373 stars 969 forks source link

removing unneeded files solution not quite right #1415

Closed GentleInfant closed 11 months ago

GentleInfant commented 11 months ago

In 'Pipes and Filters' for the exercise

Suppose you want to delete your processed data files, and only keep your raw files and processing script to save storage. The raw files end in .dat and the processed files end in .txt. Which of the following would remove all the processed data files, and only the processed data files?

The 4th answer given is rm *.* and the explanation is

The shell would expand *.* to match all files with any extension, so this command would delete all files

But extensions are optional so if the folder contained a file called, say, my.filename then filename is not an extension but it would still be deleted. It also wouldn't delete all files - it's fairly standard for compiled binaries to not have extensions in Linux so those would be missed. I think a better wording might be something like

The shell expands *.* to match all filenames containing at least one ., so this command would delete all such files which would include all .dat and .txt files.

gcapes commented 11 months ago

A PR would be welcome :)