# Number of lines in file
LC=$(wc -l $DIRNAME/$FILENAME | awk '{print $1}')
if (("$LC" > 0))
then
nonempty file steps
else
empty file steps
fi
- The value looked at has to be in quotes.
- You need to start the "then" on a new line, or have a semicolon before it.
if [ ... ]; then
- That's two round parentheses surrounding the condition, because it's numbers not strings comparison.
- Square brackets are for strings, checking file existence, or value returned from last function
if [[ -f "$DIRNAME/${FILENAME}.txt" ]]
then
...
OK, so I'm finding references toif (test -d $1)being the same as
if [-d $1]and to the use of "-eq" for comparing integers, as in
if [$# -eq 3]And if you use double square brackets, you avoid triggering an error if your variable is unset.
Good enough for now...
No comments:
Post a Comment