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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.