Chinaunix

标题: 菜鸟恳请帮忙修正! [打印本页]

作者: eidolonye    时间: 2003-09-15 08:53
标题: 菜鸟恳请帮忙修正!
要求:Print the following user information: the home directory, mail directory, path, userid and login shell together with the current date and time.
提示:Script should list the specified environment variables.  The current output of the date command, together with the userid and the full name of the user also needs to appear in this file, before the environment variables. The user’s full name must be obtained from the etc/passwd file and displayed as FAMILY NAME, followed by GIVEN NAME.
我写的:

  1. echo "$USERNAME's home directory: $HOME"
  2. echo "$USERNAME's mail directory: $MAIL"
  3. echo "$USERNAME's path: $PATH"
  4. echo -n "$USERNAME's userid:" ; grep $USERNAME /etc/passwd | awk -F: '{print $5)'
  5. echo "$USERNAME's login shell: $SHELL"
  6. echo -n "current date and time:" ; date
  7. ;;
复制代码


请问其中是不是有错误啊?
作者: binary    时间: 2003-09-15 09:24
标题: 菜鸟恳请帮忙修正!
改写了一下:


  1. $ cat a.sh
  2. echo "$LOGNAME's home directory: $HOME"
  3. echo "$LOGNAME's mail directory: $MAIL"
  4. echo "$LOGNAME's path: $PATH"
  5. echo "$LOGNAME's userid:"`grep $LOGNAME /etc/passwd | awk -F: '{print $3}'`
  6. echo "$LOGNAME's login shell: $SHELL"
  7. echo "current date and time:"`date`

复制代码
   

solaris的ksh下测试通过
作者: admirer    时间: 2003-09-15 09:35
标题: 菜鸟恳请帮忙修正!
原帖由 "binary" 发表:
   

solaris的ksh下测试通过
   


OK!
作者: eidolonye    时间: 2003-09-15 09:37
标题: 菜鸟恳请帮忙修正!
binary,万分感谢!
现在可以了!




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2