ch21.txt

来自「前面我发的那本linuxprog的随书源代码」· 文本 代码 · 共 53 行

TXT
53
字号
Chapter 21

-------------------------
Overriding Default Values
-------------------------
#!/bin/bash
if [ "$#" -eq 2 ]
   then
     mail -s $1 bob@mycomputer mary@mycomputer < $2
   elif [ "$#" -eq 3 ]
    then
     mail -s $1 $3 < $2
    else
       echo "You did not enter the correct number of arguments."
fi

----------------------------
Using Switches to Set Values
----------------------------
#!/bin/bash
if [ "$#" -eq 4 ]
   then
     if [ "$1" -= "-s" ]
        then
          declare subject="$2"
     fi
     if [ "$3" -= "-f" ]
        then
           declare file="$4"
     fi
     if [ "$1" -= "-f" ]
        then
           declare file="$2"
     fi
     if [ "$3" -= "-s" ]
        then
          declare subject="$4"
     fi
     mail -s $subject bob@mycomputer mary@mycomputer < $file
else
     echo "You did not enter the correct number of arguments."
fi

------------------------------------
Sending Multiple Emails Using a Loop
------------------------------------
#!/bin/bash
for friends in bob@mycomputer mary@mycomputer tom@mycomputer 
   do
       mail -s $1 $friends < $2
done

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?