- 24
- 0
- 约1.73万字
- 约 22页
- 2018-12-22 发布于福建
- 举报
she店ll脚本练习题
shell脚本例子集锦(习题总结)
练习一:写一个脚本?????? 1.设定变量FILE的值为/etc/passwd?????? 2.依次向/etc/passwd中的每个用户问好,并且说出对方的ID是什么??????? 形如:(提示:LINE=`wc -l /etc/passwd | cut -d -f1`)???????? Hello,root,your UID is 0.?????? 3.统计一个有多少个用户???? 答案一:#!/bin/bash?????????? file=/etc/passwd?????????? LINES=`wc -l $file | cut -d -f1`?????????? for I in `seq 1 $LINES`;do?????????? userid=`head -$I $file | tail -1 |cut -d: -f3`?????????? username=`head -$I $file | tail -1 |cut -d: -f1`?????????? echo hello $username,your UID is $userid?????????? done?????????? echo there are $LINES users???? 答案二:#!/bin/bash???????
原创力文档

文档评论(0)