Skip to main content

Loose Names Sink Scripts: Bringing Sanity to Filenames

  • Chapter
  • 827 Accesses

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. 1.

    Populate variables with the results of filename expansion (wildcards), not the output of commands such as cat or ls.

  2. 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

Chapter
USD   29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD   29.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD   39.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Learn about institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

Rights and permissions

Reprints 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

Publish with us

Policies and ethics