CS 279 - Week 9 Lecture 2 - 10-18-12
* we know that ${arrayname[*]}
we get all of the elements of the array
it so happens that ${arrayname[@]} also
gives you all of the elements of the array, BUT...
...the result is the same EXCEPT when expanding to the
items of the array within a QUOTED string
* WHEN QUOTED,
"${arrayname[*]}" returns all of the elements of
the array elements as a SINGLE word
"${arrayname[@]}" returns EACH item as a SEPARATE word
* testing this in quoted-star-at.sh
find, part 2
-------------
* when a find criterion involves a numeric argument,
it can be given in 1 of 3 ways:
n by itself - it indicates exactly the value n
-n - that indicates a value LESS THAN n
+n - that indicates a value GREATER THAN n
so, the criterion:
-size +1000c
...is satsified by files containing MORE than 1000
characters (bytes)
* a few more find criteria of note:
-type typecode
...is true if the file is of the specified type
-type d - true if file is a directory
-type f - true if file is an ordinary file
-type l - true if file is a symbolic link
...and a few other special kinds of files
* -links n - true of the file has n hard links (subject to
the numerical bit discussed earlier
* -user uname - true if the owner of the file is user
uname
* -group gname - true if the file belongs to group gname
* groups command lists your groups...
* -size n
-size nc <-- that's a letter c following the number
...be true if the file is that number of 512-byte
blocks (without the c) or that number of bytes (with
the c)
(subject to the number notation above)
* -atime n - true if file was ACCESSED n days ago
-mtime n - true if file was MODIFIED n days ago
-ctime n - true if i-node info was modified n days ago
* -newer fname - true if current file modified
MORE RECENTLY than the given file
* -perm
* octnum - true if file has exactly those permissions
* -octnum - true if file has at LEAST those permissions
* mode - CAN'T start with a dash - must match exactly
-perm =r,u+w
* -mode - must match AT LEAST these permissions
-perm -x
* -exec cmd
true if the cmd returns an exit status of 0 when
executed as a child process
* often used for the SIDE-EFFECTS of cmd...!
(e.g., removal)
* end of cmd (and all of its arguments) must be
marked with a semicolon
(and the semicolon has to be escaped so the
shell doesn't try to interpret it)
* within cmd, the notation {} indicates the
pathname of the current file being considered
find crud -name "*.bak" -type f -exec rm {} \;