Chapter 6. Loose Names Sink Scripts: Bringing Sanity to Filenames

The Naming of Files is a serious matter, This isn't just one of your Usenet flames; You may think at first it doesn't much matter But I tell you, a file should have a SENSIBLE NAME.

(with apologies to T. S. Eliot)

What is a sensible name, and what can be done about pathological filenames? In this chapter, I describe alternatives for creating acceptable filenames and provide scripts for dealing with bad names. I also provide shell replacement functions for the basename and dirname commands.

What's in a Name?

A Unix filename may contain any character except NUL and the forward slash (/). A NUL (a character in which all bits are 0) cannot be part of a filename because the shell uses it ...

Get Shell Scripting Recipes: A Problem-Solution Approach now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.