Find the answer to your Linux question:
Results 1 to 2 of 2
Hi, I just am make friend with scripting 2 weeks ago and has completely no idea how to search for the keyword to all the following syntax. Please help. var1="${mode:-AUTO}" ...
  1. #1
    Just Joined!
    Join Date
    Feb 2008
    Posts
    2

    Beginner asking for explanation of escape character

    Hi,
    I just am make friend with scripting 2 weeks ago and has completely no idea how to search for the keyword to all the following syntax. Please help.

    var1="${mode:-AUTO}"
    Does this mean that the variable var1 is assigned with the pass-in argument? Then what does ':-AUTO' means?

    var2="${mydate}_lock.text"
    var3="$DTA/mypath/.runLock"
    Asuming that mydate is 20091223, I understand that var2=20091223_lock.text, but how about var3? Why is no "{" after the "$". Also, I don't seem to find a directory of DTA/mypath. Is $DTA a keyword?

    awk -vediauto="$EDIAUTO" -vedimanual="$EDIMANUAL" \
    -vuser="$USER" --source '
    I can't find the declaration of vediauto, vedimanual or vuser. I also don't find them as keyword of awk on any website. So, may I know what are the meaning of the 3 words: vediauto, vedimanual or vuser. Also, I only find a apostsophy " ' " in the statement.

    All the above works in the program miraclely... Can you please help to advise the meaning behind them. And I would appreciate if you can advise me how to search for help of the above code in the web. I am not sure what is the keyword I should look for when googling.

    Thanks in advance.


    Regards
    Te

  2. #2
    Linux Engineer hazel's Avatar
    Join Date
    May 2004
    Location
    Harrow, UK
    Posts
    955
    Quote Originally Posted by tesp View Post
    var1="${mode:-AUTO}"
    Does this mean that the variable var1 is assigned with the pass-in argument? Then what does ':-AUTO' means?
    It's a default value to use if the variable is not set.

    var2="${mydate}_lock.text"
    var3="$DTA/mypath/.runLock"
    Asuming that mydate is 20091223, I understand that var2=20091223_lock.text, but how about var3? Why is no "{" after the "$". Also, I don't seem to find a directory of DTA/mypath. Is $DTA a keyword?
    Braces around variable names are optional. You only need them if there are following characters that could be misinterpreted as part of the name.

    DTA is the name of a variable, probably an environmental variable since it's in upper case.

    awk -vediauto="$EDIAUTO" -vedimanual="$EDIMANUAL" \
    -vuser="$USER" --source '
    I can't find the declaration of vediauto, vedimanual or vuser. I also don't find them as keyword of awk on any website. So, may I know what are the meaning of the 3 words: vediauto, vedimanual or vuser. Also, I only find a apostsophy " ' " in the statement.
    The initial -v simply means that the following string is a variable that is being assigned an initial value. So these variables are "ediauto", "edimanual" and "user". Again the values assigned to them are environmental variables.

    All the above works in the program miraclely... Can you please help to advise the meaning behind them. And I would appreciate if you can advise me how to search for help of the above code in the web. I am not sure what is the keyword I should look for when googling.
    Googling isn't the best way to answer this sort of problem. You should study the man page (or better still the info page) for bash. Or find a scripting HOWTO.
    "I'm just a little old lady; don't try to dazzle me with jargon!"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...