免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1320 | 回复: 3
打印 上一主题 下一主题

菜鸟恳请帮忙修正! [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 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. ;;
复制代码


请问其中是不是有错误啊?

论坛徽章:
0
2 [报告]
发表于 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下测试通过

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
3 [报告]
发表于 2003-09-15 09:35 |只看该作者

菜鸟恳请帮忙修正!

原帖由 "binary" 发表:
   

solaris的ksh下测试通过
   


OK!

论坛徽章:
0
4 [报告]
发表于 2003-09-15 09:37 |只看该作者

菜鸟恳请帮忙修正!

binary,万分感谢!
现在可以了!
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP