24.12.2012 Views

CSC322 C Programming and UNIX - Department of Computer ...

CSC322 C Programming and UNIX - Department of Computer ...

CSC322 C Programming and UNIX - Department of Computer ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Effective Shell Use: Globbing<br />

Idea: Use simple patterns to describe sets <strong>of</strong> filenames<br />

A string is a wildcard pattern if it contains one <strong>of</strong> ?, * or [<br />

A wildcard pattern exp<strong>and</strong>s into all file names matching it<br />

– A normal letter in a pattern matches itself<br />

– A ? in a pattern matches any one letter<br />

– A * in a pattern matches any string<br />

– A pattern [l1. . . ln] matches any one <strong>of</strong> the enclosed letters (exception: ! as<br />

the first letter)<br />

– A pattern [!l1. . . ln] matches any one <strong>of</strong> the characters not in the set<br />

– A leading . in a filename is never matched by anything except an explicit<br />

leading dot<br />

– For more: man 7 glob<br />

Important: Globbing is performed by the shell!<br />

Stephan Schulz 46

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!