0

I am working with perl in csh. Now I am using get options thing. I want to use as

myperl -f temp1*.txt

But it won't go into code and give me error 'No match.' Currently I below things are working..

myperl -f temp1\*.txt

and

myperl -f "temp1*.txt"

How to get first thing working?

karate_kid
  • 145
  • 1
  • 5
  • 14

1 Answers1

1

It can't work. The asterisk is a special char in shell. So you need to escape it anyway.

Most characters (*, ', etc) are not interpreted (ie, they are taken literally) by means of placing them in double quotes (""). They are taken as is and passed on to the command being called. An example using the asterisk (*) goes:

$ echo *
case.shtml escape.shtml first.shtml 
functions.shtml hints.shtml index.shtml 
ip-primer.txt raid1+0.txt
$ echo *txt
ip-primer.txt raid1+0.txt
$ echo "*"
*
$ echo "*txt"
*txt

Source

  • What I mean if if simply ls * is working without using '\\*'. Then it should work for temp*.txt, too, right? – karate_kid Jul 23 '13 at 06:31
  • Nope. Take a look [here](http://unix.stackexchange.com/questions/62660/the-result-of-ls-ls-and-ls) –  Jul 23 '13 at 06:34
  • If `perl temp*.txt` fails then `ls temp*.txt` will also fail with the same error message. Repeat: the glob is expanded by the shell, your program doesn't run at all when the glob fails. (Bash has an option to change this; perhaps csh does, too?) – tripleee Jul 23 '13 at 06:35
  • Actually myperl -f tmp*.txt is failing. Does it have something to do with when being used with options? – karate_kid Jul 23 '13 at 06:39
  • The point is, that you need to use one of your 2 last ways. The asterisk need to be escaped. But instead of using an asterisk, you can use another char which will be replaced in your script. –  Jul 23 '13 at 06:56
  • @karate_kid `ls` is designed to accept many inputs at once. It is possible that `myperl` only expects one . This would cause the discrepancy between the two programs. The shell expands `*` *before* passing to the program *unless* it is escaped with the `\\` or with quotes. – SethMMorton Jul 25 '13 at 21:51