Changes

Jump to navigation Jump to search
1,466 bytes added ,  17:21, 19 October 2009
Line 65: Line 65:  
</pre>
 
</pre>
 
===Examples===
 
===Examples===
<source lang="bash">echo -e "\a Ding dong\a"
+
<source lang="bash">echo "Pizza bill \$22.5"
 +
echo -e "\a Ding dong\a"
 
echo "CIFS path must be \\\\NT-Server-Name\\ShareName"
 
echo "CIFS path must be \\\\NT-Server-Name\\ShareName"
 
echo -e "Sr.no\t DVD (price) "
 
echo -e "Sr.no\t DVD (price) "
Line 74: Line 75:  
echo "\*"
 
echo "\*"
 
echo "\@"</source>
 
echo "\@"</source>
 +
====Continue command on next line====
 +
You can use the backslash (\) as last character on line to continue command on next line:
 +
<source lang="bash">echo "A monkey-tailed boy named Goku is found by an old martial \
 +
>arts expert who raises him as his grandson. One day Goku meets a \
 +
>girl named Bulma and together they go on a quest to retrieve the seven Dragon Balls"</source>
 +
You can also use the backslash while writing program or [[Writing_your_first_shell_function|function]]:
 +
<source lang="bash"># Purpose: clean /tmp/$domain ?
 +
check_temp_clean() {
 +
        [ "$SERVER_MODE" = "daemon" ] || return 1
 +
        [ "$SERVER_MODE"  = "init"    ] && return 0
 +
        # note use of the backslash character to continue command on next line   
 +
        [ "$SERVER_MODE"  = "clean" \
 +
          -a -e /usr/local/etc/nixcraft/lighttpd/disk_cache.init ] && return 0
 +
        return 1
 +
}</source>
    +
====Protecting command line arguments====
 +
Type the following command to find out all c program file (*.c):
 +
<source lang="bash">find $HOME -name *.c</source>
 +
In the above example, the *.c is expanded by the bash shell. It will try to match all filename ending with .c in the current directory such as main.c, lib1.c, lib2.c, ssh.c, auth.c etc. You can escape the wild card using the backslash as the escape character:
 +
<source lang="bash">find $HOME -name \*.c</source>
 +
OR use the [[quoting|double quote]]:
 +
<source lang="bash">find $HOME -name "*.c"</source>
 
[[Category:Variables and Quoting]]
 
[[Category:Variables and Quoting]]
 
{{navigation
 
{{navigation
 
|previous=Echo Command|Display the value of shell variables
 
|previous=Echo Command|Display the value of shell variables
 
|next=Export Variables|The export statement}}
 
|next=Export Variables|The export statement}}

Navigation menu