[CentOS] bash off topic

Jerry Geis

jerry.geis at gmail.com
Thu May 16 16:57:43 UTC 2019


I have a simple bash script it will take arguments from a file that has
quotes.

my file arg.txt would be this
-lt "*.txt"

my script file would be
LS_ARG=`cat arg.txt`
ls $LS_ARG

it does not run properly:
 sh -x ./arg.sh
++ cat arg.txt
+ LS_ARG='-lt "*.txt"'
+ ls -lt '"*.txt"'
ls: cannot access "*.txt": No such file or directory


How do I resolve that ?  If the quotes are not in my file it all works
fine. I think its because it looks like the extra single quotes it puts
around the "*.txt" - or - '"*.txt"'  - how do I do this ?  This is just a
short example of my larger need.

Thanks,

Jerry


More information about the CentOS mailing list