File Name Expansion and Wild Cards


File Name Expansion and Wild Cards

Before we cover additional file system related commands, it is worth taking a look at file name expansion. An overview of file name expansion is useful to ensure that you're comfortable with this topic before we cover additional commands.

Table 21-2 lists some common file name expansion and pattern matching.

Table 21-2. File Name Expansion and Pattern Matching

Character(s)

Example

Description

*

1) ls *.c

Match zero or more characters

?

2) ls conf.?

Match any single character

[list]

3) ls conf.[co]

Match any character in list

[lower-upper]

4) ls libdd.9873[5-6].sl

Match any character in range

str{str1,str2,str3,...}

5) ls ux*.{700,300}

Expand str with contents of {}

~

6) ls -a ~

Home directory

~username

7) ls -a ~gene

Home directory of username

The following descriptions of the examples shown in Table 21-2 are more detailed:

  1. To list all files in a directory that end in ".c", you could do the following:


    $   ls  *.c
                 conf.  SAM.c  conf.c

  2. To find all the files in a directory named "conf" with an extension of one character, you could do the following:


    $   ls  conf.?
               conf.c  conf.o  conf.1

  3. To list all the files in a directory named "conf" with only the extension "c" or "o," you could do the following:


    $   ls  conf.{co}
               conf.c  conf.o

  4. To list files with similar names but a field that covers a range, you could do the following:


    $   ls  libdd9873[5-6].sl
                 libdd98735.sl  libdd98736.sl

  5. To list files that start with "ux" and have the extension "300" or "700," you could do the following:


    $   ls  ux*.{700,300}
               uxbootlf.700  uxinstfs.300

  6. To list the files in your home directory, you could use ~ (tilde):


    $   ls  -a  ~
               .          . cshrc .org  .login      .shrc.org
               ..        .exrc        .login.org  .cshrc
                           .history    .profile

  7. To list the files in the home directory of a user , you could do the following:

     $  ls -a ~gene  .          .history    splinedat   under.des    ..         .login      trail.txt   xtra.part    .chsrc     .login.org  ESP-File    .cshrc.org .profile    Mail    .exrc      .shrc.org   opt 


HP-UX 11i Systems Administration Handbook and Toolkit
HP-UX 11i Systems Administration Handbook and Toolkit (2nd Edition)
ISBN: 0131018833
EAN: 2147483647
Year: 2003
Pages: 301

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net