Prevent * to be expanded in the bash script

Posted by Alex Farber on Stack Overflow See other posts from Stack Overflow or by Alex Farber
Published on 2010-03-18T14:40:15Z Indexed on 2010/03/18 14:41 UTC
Read the original article Hit count: 500

Filed under:
|
|

Linux bash script:

#!/bin/bash

function Print()
{
    echo $1
}

var="*"
Print $var

Execution results:

[email protected]:~/tmp$ ./sample-script 
sample-script

"*" is expanded to the list of files, which is actually script itself. How can I prevent this and see actual variable value? In general case, var can be more complicated than "*", for example: "home/alex/mydir/*".

© Stack Overflow or respective owner

Related posts about linux

Related posts about scripting