what is wrong with my script? I am trying to call a function to see if a file is larger than a specified amount. If it is, i would like to remove the second file. If it is not larger than the specified amount than i would like the program to exit. Instead, I get this error message:
“syntax error near unexpected token `FILE'”
Can someone please help or direct me where I can get some help? Thanks. I have a Bash shell.
function e{
FILE = $1
FILESIZE=$(stat -c%s "$FILE")
if [ "$FILESIZE" -gt 2048 ]; then
echo "File $1 exists"
`rm $2`
else
echo "File $1 does not exist"
exit
fi
}
e AD4_1hit.paired_mult.bam AD4_1hit.halfmapping_transloc.bam
You need to remove the spaces around the
=…BTW, you don’t need the command-substitution `…` syntax around your
rmcommand.