linux的ac命令 linux ac( 二 )


Linux下使用ac命令显示用户总的连接时间linux下使用ac命令显示用户总linux的ac命令的连接时间在linux下linux的ac命令,linux的ac命令我们可以用ac命令显示用户登录主机linux的ac命令的时间信息 。目前登录用户的连接时间ac命令中,使用
d
选项 , 可以将输出的时间按天来显示 。在本例中,今天我已经登录系统超过6个小时了,在12月1日 , 我登录系统的时间大约是1个小时 。
$
ac
–d
Dec
1
total
1.08Dec
2
total
0.99Dec
3
total
3.39Dec
4
total
4.50Today
total
6.10所有用户的连接时间就像下面所显示的,可以用-p
显示所有用户的连接时间 。注意这显示了每一个用户的总的连接时间 。$
ac
-pjohn
3.64madison
0.06sanjay
88.17nisha
105.92ramesh
111.42total
309.21显示指定用户的连接时间
$
ac
-d
sanjayJul
2
total
12.85Aug
25
total
5.05Sep
3
total
1.03Sep
4
total
5.37Dec
24
total
8.15Dec
29
total
1.42Today
total
2.95
Linux文件相关命令grep命令linux的ac命令:
grep命令是非常重要linux的ac命令的命令linux的ac命令,可以对文本进行查找和搜索
常用参数如下:
常用实例:
1、在多个文件中查找:
grep "file" file_1 file_2 file_3
2、输出除之外的所有行 -v 选项:
grep -v "file" file_name
3、标记匹配颜色 --color=auto 选项:
grep "file" file_name --color=auto
4、使用正则表达式 -E 选项:
grep -E "[1-9]+"
egrep "[1-9]+"
5、只输出文件中匹配到的部分 -o 选项:
echo this is a test line. | grep -o -E "[a-z]+."
line.
echo this is a test line. | egrep -o "[a-z]+."
line.
6、统计文件或者文本中包含匹配字符串的行数-c 选项:
grep -c "text" file_name
2
7、输出包含匹配字符串的行数 -n 选项:
grep "text" -n file_name

cat file_name | grep "text" -n
8、多个文件
grep "text" -n file_1 file_2
9、搜索多个文件并查找匹配文本在哪些文件中:
grep -l "text" file1 file2 file3...
10、grep递归搜索文件
在多级目录中对文本进行递归搜索:
grep "text" . -r -n
11、忽略匹配样式中的字符大小写:
echo "hello world" | grep -i "HELLO"
hello
12、选项 -e 指定多个匹配样式:
echo this is a text line | grep -e "is" -e "line" -o
is
line
13、也可以使用-f选项来匹配多个样式 , 在样式文件中逐行写出需要匹配的字符 。
cat patfile
aaa
bbb
echo aaa bbb ccc ddd eee | grep -f patfile -o
【linux的ac命令 linux ac】 14、在grep搜索结果中包括或者排除指定文件:
只在目录中所有的.php和.html文件中递归搜索字符"main()"
grep "main()" . -r --include *.{php,html}
15、在搜索结果中排除所有README文件
grep "main()" . -r --exclude "README"
16、在搜索结果中排除filelist文件列表里的文件
grep "main()" . -r --exclude-from filelist
touch abc.txt创建一个名为abc.txt的文件
touch -r指定文件时间与参考文件相同
touch -t 201608012234.55[yyyymmddhhmm.ss]abc.txt更改文件为指定的时间
touch temp创建一个名为temp的文件
vi编辑器有三种模式,命令行模式、编辑模式、底行模式 。
vi 文件名进入命令行模式,Insert进入编辑模式 , 编辑完成Esc退出编辑模式 , :wq进入底行模式并保存修改 , :q直接退出保存 。

推荐阅读