CHAPTER 6

image

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, we describe alternatives for creating acceptable filenames and provide scripts for dealing with bad names. We 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 ...

Get Shell Scripting Recipes: A Problem-Solution Approach, Second Edition 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.