LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   shell symbols ? (https://www.linuxquestions.org/questions/linux-newbie-8/shell-symbols-869043/)

Ribo01 03-16-2011 06:01 PM

shell symbols ?
 
In shell scriptings, what do or what does this symbol do or mean ? "."(octet), ";" (semicolon)? Would really like to know? Cause I saw a written script if [ -f /etc/file ];then. . /etc/file. Wondering, the "." is meant to be source, so is "." the same thing as "source" ?thank you.

Ignotum Per Ignotius 03-16-2011 06:14 PM

Formatting the snippet using BBCode to make it easier to read...

Code:

if [ -f /etc/file ];
then
  . /etc/file
fi

Yes, the . performs the same task as source (see the bash manual page and look for the section "SHELL BUILTIN COMMANDS"). The semicolon here is part of the syntax for the if statement (again see the bash man page --- it's described under "SHELL GRAMMAR" and is towards the end of the sub-section titled "Compound Commands").

The if statement above simply checks that /etc/file exists and is a regular file, and if it exists, then it sources it.

Hope that answers your query! :)

chrism01 03-16-2011 07:54 PM

Also, the ';' in that usage is redundant; a newline is sufficient to separate cmds for the parser.
http://rute.2038bug.com/index.html.gz
http://tldp.org/LDP/Bash-Beginners-G...tml/index.html
http://www.tldp.org/LDP/abs/html/


All times are GMT -5. The time now is 08:54 AM.