linux - How to get this bash script to work if the variable "fileName" contains space? -
#!/bin/bash -x echo "enter file name: " read filename filename=`pwd`"/$filename" if [ -f $filename ]; echo "file present" fi
even if change value of filename adding quotes @ starting , end.. script still doesnt work.
wrapping in double-quotes works me:
#!/bin/bash -x echo "enter file name: " read filename filename=`pwd`"/$filename" if [ -f "$filename" ]; echo "file present" fi
i believe take care of special characters, including quotes themselves.
Comments
Post a Comment