Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Design a wildcard that will match the files haiku.txt and mobydick.txt but not jabberwocky.txt in your Home directory.

Expand
titleAnswer...

There are always multiple ways of doing things in Unix. Here are two possible answers:

Code Block
languagebash
ls [hm]*.txt
ls {haiku,jabberwocky}.txt 


File attributes

Let's revisit a listing of our Home directory contents. Before we created any files, an ls -l listing looked something like this:

Image Added

Ignoring that "total 779" line, there are 9 whitespace-separatedcolumns in this long listing:

  1. file permissions - a 10-character field
  2. number of sub-directories or symbolic links associated with a directory - rarely important
  3. account name of the file owner
  4. Unix group associated with the file
  5. file size
  6. last modification month
  7. last modification day
  8. last modification year, or last modification hour/minute if within the last year
  9. file name

Notice I call everything a file, even directories. That's because directories are just a special kind of file – one that contains information about the directory's contents.

Owner and Group

A file's owner is the Unix account that created the file (here student01, me). That account belongs to one or more Unix groups, and the group associated with a file is listed in field 4.

The owner will always be a member of the group associated with a file, and other accounts may also be members of the same group. The Unix group for our class is CCBB_Workshops_1. (To see the Unix groups you belong to, just type the groups command.)

Permissions

File permissions (and some information about the file type) are encoded in that 1st 10-character field. Permissions govern who can access a file, and what actions they are allowed.

  • character 1 describes the file type (d for directory, - for regular file, l for symbolic link)
  • the remaining 9 characters are 3 sets of 3-character designations
    • characters 2-4: what the owning user account can do
    • characters 5-7: what other members of the associated Unix group can do
    • characters 8-19: what other non-group members can do

Each of the 3-character sets describes if read ( r ) write ( w ) and execute ( x ) actions are allowed, or not allowed ( - ).