Personal tools
You are here: Home Members pacneil's Home Beginning Linux Filename Expansion
Navigation
Log in


Forgot your password?
New user?
 
Document Actions

Filename Expansion

by Neil Schneider last modified 2005-06-08 12:47

Filename Expansion

next up previous contents index
Next: Redirection Up: Shortcuts Previous: Tab Completion

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 index
Next: Redirection Up: Shortcuts Previous: Tab Completion
2005-05-10

Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: