next up previous contents
Next: 1.5.3 Redirection Up: 1.5 Shortcuts Previous: 1.5.1 Tab Completion   Contents

1.5.2 Filename Expansion

You can use wildcard characters to expand commands, to speed up access. Suppose you knew their was a configuration file, that you needed to modify, because you recently added some new libraries. You know the configuration file is in /etc and you know it begins with an l, but you can't remember the name. You could use the filename expansion capabilities of the shell to find ld.so.conf.

# cd /etc

# ls -d l*

ld.so.cache localtime@ logrotate.conf lynx.cfg

ld.so.conf localtime.rpmnew@ logrotate.d/

lilo.conf login.defs ltrace.conf
The ``*'' means substitute any or no string following the l. The -d argument says don't traverse directories. So the command returns all files and directories, in the current directory, that begin with the letter l. If we knew the file began with ld we might form the command

# ls -d ld*

ld.so.cache ld.so.conf
The ``?'' substitutes for any single character. It is more usefull for seperating similar filenames with single character differences. If we wanted to see a listing of all the files under /usr/man/ we could do the following;

# cd /usr/man

# ls

man1/ man3/ man5/ man7/ man9/ mann/

man2/ man4/ man6/ man8/ manl/ whatis

# ls man?

<returned_long_list>


next up previous contents
Next: 1.5.3 Redirection Up: 1.5 Shortcuts Previous: 1.5.1 Tab Completion   Contents