码迷,mamicode.com
首页 > 系统相关 > 详细

Linux_几个符号命令

时间:2016-09-07 12:42:16      阅读:155      评论:0      收藏:0      [点我收藏+]

标签:

一、管道符号 | (将前面命令的输出结果传给后面的命令)

[eRrsr@hadoop09-linux ~]$ cat /etc/passwd | grep "^root"
root:x:0:0:root:/root:/bin/bash

二、重定向符号 [>] [<]

[root@hadoop09-linux ~]# df > /usr/tmp/df.txt # >:输入重定向 即将命令结果重定向给df.txt,需要root权限,df.txt若不存在则新建
[root@hadoop09-linux ~]# cat /usr/tmp/df.txt 
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda2             18339256   2757204  14650468  16% /
tmpfs                   506272        72    506200   1% /dev/shm
/dev/sda1               297485     33538    248587  12% /boot
/dev/sr0               4251346   4251346         0 100% /media

  

[root@hadoop09-linux ~]# wc -l < /usr/tmp/df.txt  # <:输出重定向 即将df.txt输出给wc命令 -l:统计行数
5

 

[root@hadoop09-linux ~]# pwd > /dev/null       # 若要执行命令,但不要求输出,可以重定向到/dev/null
[root@hadoop09-linux ~]# 

  

三、追加符号 [>>] [<<]

[root@hadoop09-linux ~]# df >> /usr/tmp/df.txt 
[root@hadoop09-linux ~]# cat /usr/tmp/df.txt 
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda2             18339256   2757204  14650468  16% /
tmpfs                   506272        72    506200   1% /dev/shm
/dev/sda1               297485     33538    248587  12% /boot
/dev/sr0               4251346   4251346         0 100% /media
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda2             18339256   2757208  14650464  16% /
tmpfs                   506272        72    506200   1% /dev/shm
/dev/sda1               297485     33538    248587  12% /boot
/dev/sr0               4251346   4251346         0 100% /media

  

[root@hadoop09-linux ~]# cat << eof   # eof 文档起点
> hello Linux               # 文档内容第一行
> Linux: Hello eRrsr           # 文档内容第二行
> eof                   # eof 文档终点 
hello Linux
Linux: Hello eRrsr

四、家目录 ~

[root@hadoop09-linux ~]# pwd
/root

  

[root@hadoop09-linux ~]# su - eRrsr
[eRrsr@hadoop09-linux ~]$ pwd
/home/eRrsr

Linux_几个符号命令

标签:

原文地址:http://www.cnblogs.com/eRrsr/p/5848839.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!