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

Popular posts from this blog

java - JavaFX 2 slider labelFormatter not being used -

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -