shell - for loop in UNIX Script is not working -
for in `cat ${dir}/${indicator_flist}` x=`ls $i|wc -l` echo $x echo $x>>txt.txt done
i have code check if file present in directory or not not working , gives error this:
not foundtage001/dev/badfiles/rfm_dw/test_dir/sales_crdt/xyz.txt
you can see there no space between not found , file path.
i have code check if file present in directory or not ...
it seems you're trying read list of files ${dir}/${indicator_flist}
, trying determine if actually exist. main problem is:
- you're trying parse
ls
in order figure whether file exists.
this results in sort of output see; mix of stderr
, stdout
. use test
operator instead given below.
the following give tell whether file exists or not:
while read line; [ -e "${line}" ] && echo "${line} exists" || echo "${line} not exist"; done < ${dir}/${indicator_flist}
Comments
Post a Comment