[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Avoiding pattern expansion in bash?



Olle Eriksson wrote:
This might be a little off topic but here it goes anyway.

I am writing a bash script that takes as input a file expression such as "/etc/lilo.conf" or "/boot/config*" etc. I want to keep those strings as they are (including the *) and echo them to a file. How do I prevent bash from doing its pattern expansion where it turns /boot/config* into a list of files that match the expression. If I use echo "$1" it becomes the first file that matches the expression /boot/config*. If I use echo "$*" it becomes a space separated list of all the files that match the expression. I want none of this.

Any ideas?

Regards
Olle Eriksson


pretzalz@Pretzalz:/tmp$ cat test.sh
#!/bin/sh

echo "$1"
pretzalz@Pretzalz:/tmp$ ./test.sh '/boot/config*'
/boot/config*

Not sure I understand what exactly is the problem you are having...

Attachment: signature.asc
Description: OpenPGP digital signature


Reply to: