Summary
I hope you have no doubt about my feelings regarding badly formed filenames. If shell scripts were never used, it wouldn’t matter. But despite the popularity of languages such as Perl and Python, it is exceedingly unlikely that shell scripts will ever disappear entirely. They are a natural complement to the command line.
You may have realized that, despite my ranting over @!$#%^*& filenames (I’ve run out of polite things to call them), I’ve just given you a chapter full of scripts that can process any filenames you can come up with. It is possible to do it, but a lot of scripting techniques are ruled out because of them. If you need to write shell scripts that work on spaced-out filenames, remember two things:
-
1.
Populate variables with the results of filename expansion (wildcards), not the output of commands such as cat or ls.
-
2.
Enclose the variables in quotes when you use them: “$filename” not $filename.
This is a preview of subscription content, log in via an institution.
Buying options
Tax calculation will be finalised at checkout
Purchases are for personal use only
Learn about institutional subscriptionsPreview
Unable to display preview. Download preview PDF.
Rights and permissions
Copyright information
© 2005 Chris F. A. Johnson
About this chapter
Cite this chapter
(2005). Loose Names Sink Scripts: Bringing Sanity to Filenames. In: Shell Scripting Recipes. Apress. https://doi.org/10.1007/978-1-4302-0024-6_6
Download citation
DOI: https://doi.org/10.1007/978-1-4302-0024-6_6
Publisher Name: Apress
Print ISBN: 978-1-59059-471-1
Online ISBN: 978-1-4302-0024-6
eBook Packages: Professional and Applied ComputingProfessional and Applied Computing (R0)Apress Access Books