In article
<
3e6abacd-6955-4f1f...@b26g2000vbt.googlegroups.com>,
The Derfer <
der...@gmail.com> wrote:
> This is a script I wrote in Oracle Enterprise Linux 5.
>
> This script yields the errors that follow:
>
> #!/bin/bash
> CWD=/directory
> cd $CWD
> for filename in `ls *.zip` do
You need a semicolon or newline before "do". Also, there's no reason to
use "ls", you can just write:
for filename in *.zip; do
> s=$(ls -lah $filename | awk '{ print $5}');
> if [ $s -eq 0 ] ; then
> echo "File $filename has zero file size in $CWD" | mailx -s " ERROR:
> zero size file found"
x...@yz.com
> fi
> done
>
>
> bash-3.2$ ./check2.sh
> ./check2.sh: line 5: syntax error near unexpected token `s=$(ls -lah
> $filename | awk '{ print $5}')'
> ./check2.sh: line 5: `s=$(ls -lah $filename | awk '{ print $5}');'
>
>
> Don't understand why it errors out on that particular line.
It's expecting "do" on the line after "for", but instead it got s=$(...).
> If I do this on a single command line, there's no problem with the
> syntax of the
> "s=" line:
> bash-3.2$ s=$(ls -lah $filename | awk '{ print $5}'); echo $s
>
>
> Ideas?
>
> Thanks in advance.
--
Barry Margolin,
bar...@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***