查看当前日期以及登陆用户:

cat test1:

  #!/bin/bash
  # This script displays the date and who's logged on
  echo -n The time and date are:
  date
  echo "Let's see who's logged into the system:"
  who

添加执行权限:chmod u+x test1

执行./test1,得带结果如下:

The time and date are:Wed Oct 15 20:54:48 CST 2014
Let's see who's logged into the system:
clarck   :0           2014-10-14 16:20 (:0)
clarck   pts/1        2014-10-15 17:56 (:0)
clarck   pts/4        2014-10-15 20:50 (:0)

 

相关文章: