1、显示当前系统上root、fedora或user1用户的默认shell;[root@mageedu~]#useraddfedora
[root@mageedu~]#useradduser1
[root@mageedu~]#egrep"^(root|fedora|user1)"/etc/passwd|cut-d:-f1,7
root:/bin/bash
fedora:/bin/bash
user1:/bin/bas2、找出/etc/rc.d/init.d/function..
分类:
系统相关 时间:
2016-09-06 01:30:27
阅读次数:
300
1、显示当前系统上root、fedora或user1用户的默认shell;#/etc/passwd文件中每行第一字段为用户名,第七字段为默认bash,使用^进行行首锚定,然后使用egrep中的正则表达式元字符“|”来匹配,使用cut命令切割出第一和第七字段得到结果。
[root@localhost~]#egrep"^root|fedora|..
分类:
其他好文 时间:
2016-09-06 01:26:00
阅读次数:
167
本周作业内容:显示当前系统上root、fedora或user1用户的默认shell;#egrep"^(root|user1|fedora)"/etc/passwd|cut-d:-f72、找出/etc/rc.d/init.d/functions文件中某单词后面跟一组小括号的行,形如:hello();#egrep"^[[:alpha:]]+\(\)"/etc/rc.d/init.d/functions3、使用echo..
分类:
其他好文 时间:
2016-09-06 01:22:12
阅读次数:
166
1、显示当前系统上root、fedora或user1用户的默认shell;egrep‘^(root|fedora|user1)\>‘/etc/passwd|cut-d:-f7
#|表示或者,以:为分隔截取第7段2、找出/etc/rc.d/init.d/functions文件中某单词后面跟一组小括号的行,形如:hello();grep-o"^[_[:alpha:]]+\(\)"/etc/rc.d/in..
分类:
其他好文 时间:
2016-09-05 17:39:26
阅读次数:
150
1、显示当前系统上root、fedora或user1用户的默认shell;答:Linux的哲学思想之一:组合单一目的的小程序,完成复杂任务;
第一步:使用扩展正则表达式egrep或grep–E显示出匹配到的用户信息;
^:行首锚定,用于模式的最左侧;\>或\b:词尾锚定,用于单词模式的右侧;
[ro..
分类:
其他好文 时间:
2016-09-05 17:36:58
阅读次数:
237
1、显示当前系统上root、fedora或user1用户的默认shell;egrep"^root|^fedora|^user1"/etc/passwd|cut-d:-f1,72、找出/etc/rc.d/init.d/functions文件中某单词后面跟一组小括号的行,形如:hello();grep"\<[[:alpha:]]\+\>()"/etc/rc.d/init.d/functions3、使用echo命令..
分类:
其他好文 时间:
2016-09-05 17:27:26
阅读次数:
127
1、显示当前系统上root、fedora或user1用户的默认shell;[root@bogon~]#useraddfedora#添加用户fedora
[root@bogon~]#useradduser1#添加用户user1
[root@bogon~]#egrep‘^(root|fedora|user1)‘/etc/passwd|cut-d:-f1,7
#使用表达式(root|fedora|user1)查找root、fedora或user1
r..
分类:
编程语言 时间:
2016-09-05 17:25:03
阅读次数:
259
1、显示当前系统上root、fedora或user1用户的默认shell;grep-E"^root|^fedora|^user1\>"/etc/passwd|cut-d:-f1,72、找出/etc/rc.d/init.d/functions文件中某单词后面跟一组小括号的行,形如:hello();grep-o"[[:alpha:]]\+()"/etc/rc.d/init.d/functions3、使用echo命令输..
分类:
其他好文 时间:
2016-09-05 09:19:41
阅读次数:
150
1、显示当前系统上root、fedora或user1用户的默认shell;#!/bin/bash
foruserinrootfedorauser1
do
id$user&>/dev/null
if[$?-eq0]
then
cat/etc/passwd|grep^$user|cut-d:-f7
fi
done
//输出:
//下面是或的输出
/bin/bash
#!/bin/bash
foruserinrootmysql
do
id$user&..
分类:
其他好文 时间:
2016-09-04 17:53:04
阅读次数:
228
1、显示当前系统上root、fedora或user1用户的默认shell;#useraddfedora#useradduser1#grep-E"^(root|fedora|user1)\>"/etc/passwd|cut-d:-f1,7(注意是使用扩展正则表达式)^:行首|:或者():将一个或多个字符捆绑在一起,当作一个整体进行处理cut-d分隔符-fN,M:指定分隔..
分类:
其他好文 时间:
2016-09-04 17:48:12
阅读次数:
193