Aren't bash script variable untyped (converted automatically)? -


touch "data" if [ $(stat -c%s "data") < 1024 ];     echo "not file" fi 

it cannot check whether file size less 1mib. (of course, data should empty file.)

it give error:

./chk.sh: line 2: 1024: no such file or directory 

aren't bash script variable untyped (converted automatically)?

you should using -lt instead of < integer comparison

= , != used string comparisons

< , > used redirection


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

python - NameError: name 'subprocess' is not defined -