比较位置参数并写入日志文件

时间:2017-04-28 03:35:46

标签: bash ubuntu scripting

我试图在Ubuntu中创建一个bash脚本,但我需要一些帮助。以下是我的指示。

创建一个名为matchit的脚本,完成以下操作。

  1. 接受2个位置参数
  2. 如果参数是相同的echo“Hello,%username%,我们有匹配!”
  3. 如果它们与echo不匹配“这些参数不相同,%username%”
  4. 附加到日志文件〜/ bashlog / mylog“%username%执行的脚本,收到的变量%parameter1%和%parameter2%”
  5. 以下是我到目前为止的情况。非常感谢任何帮助!

    #!/bin/bash
    
    echo "Enter Name"
    read user
    
    if [ $user = vortex ]
            then echo "Hello,%username%, we have a match!"
            else echo "These parameters are not the same, %username%"
    fi
    
    >> /home/vortex/bashlog/mylog "Script executed by %username%, variable recieved where %parameter1% and %parameter2%"
    

1 个答案:

答案 0 :(得分:0)

player.playVideo();脚本下面会有

matchit

[1] - GNU Shell Param Expansion