Dec 6, 2011

Writing a Shell Script


Paired Bash Control Structures

if, while, until, for and case
Paired? Yes, starts and ends with a tag.

-f
checks if it is a regular file

-d
check if the file is a directory

-e
check if the file exists

-f
check if the file is a regular file

-g
check if the file has SGID permissions ???

-r
check if the file is readable

-s
check if the file's size is not 0

-u
check if the file has SUID permissions

-w
check if the file is write-able

-x
check if the file is executable

if [ -f /etc/foo ]; then
If-then control structure.

Finding and listing files with a string of interest in a directory and sub-directories.
find . -type f -exec grep "stringofinterest" {} \; -print


References:
1. Tips for Linux: codecoffee.com


0 Comments:

Post a Comment