Hello William, I'm no expert in shell scripting, but why not just do: if [ -f *.txt ]; then echo "yes" else echo "no" ; fi
HTH, André On Mar 3, 2011, at 11:35 PM, William Windels wrote: > Hello, > > Can someone help me with a litle bash-script? > > I would like to test if there is a txt-file in the current working directory. > > I was thinking about the following code for the bashscript: > > var=${ls *.txt} && if [ -n "$var" ]; then echo "yes" else echo "no" ; fi > > The error I have here is: > ${ls *.txt}: bad substitution > > the -n options looks if the variable is not empty , I think. > > Could someone help me pls? > > Thx for your help, > > best regards, > William Windels > > -- > You received this message because you are subscribed to the Google Groups > "MacVisionaries" group. > To post to this group, send email to macvisionaries@googlegroups.com. > To unsubscribe from this group, send email to > macvisionaries+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/macvisionaries?hl=en. > -- You received this message because you are subscribed to the Google Groups "MacVisionaries" group. To post to this group, send email to macvisionaries@googlegroups.com. To unsubscribe from this group, send email to macvisionaries+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/macvisionaries?hl=en.