Chapter 10. Working with Files

In this chapter, we discuss some of the more common commands for working with files: how to list files, modify their timestamps, create temporary files, find files in a directory hierarchy, apply commands to a list of files, determine the amount of filesystem space used, and compare files.

Listing Files

The echo command provides one simple way to list files that match a pattern:

$ echo /bin/*sh                          
            Show shells in /bin
/bin/ash /bin/bash /bin/bsh /bin/csh /bin/ksh /bin/sh /bin/tcsh /bin/zsh

The shell replaces the wildcard pattern with a list of matching files, and echo displays them in a space-separated list on a single line. However, echo does not interpret its arguments further, and thus does not associate them with files in the filesystem.-

Get Classic Shell Scripting 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.