-   Programming (
-   -   assigning value * to variable problem (

coolpraz 01-13-2013 12:03 AM

assigning value * to variable problem
im writting script where in one point i got and unexpected result
here example


echo $ASDF

This display file and folder of the same folder where script is or from script is executed. I want to just display *

colucix 01-13-2013 02:54 AM

Just use double quotes around the value, as you did in the variable assignment:

echo "$ASDF"
Double quotes don't prevent variable substitution, but protect the asterisk from the filename expansion. Quoted from

Using double quotes the literal value of all characters enclosed is preserved, except for the dollar sign, the backticks (backward single quotes, ``) and the backslash.

konsolebox 01-13-2013 03:41 AM

Another way to interpret it is that double quotes create a new string based on its contents and keeps it as is or prevents it from being re-expanded or re-parsed from the outside.

All times are GMT -5. The time now is 02:03 AM.