linux中action命令啥意思,Linux经典命令

Linux 命令

1:创建一个目录

mkdir  /data

2:查询你创建的data目录

ls -ld /data

递归创建目录

mkdir  -p /a/b/c

查看目录结构

tree a

如果出现

[root@York ~]# tree a

-bash: tree: command not found

就使用 yum -y install tree

[root@York ~]# tree /a/

/a/

└── b

└── c

3:在data目录下建一个文件并且查看该文件

[root@York ~]# touch /data/zhouyang.txt

[root@York ~]# ls /data/

zhouyang.txt

一次创建多个文件

[root@York ~]# touch {zhangsan,li,wangwu}.txt

[root@York ~]# ls

anaconda-ks.cfg  install.log  install.log.syslog  li.txt  wangwu.txt  zhangsan.txt

创建100个文件

[root@York ~]# for f in `seq 100`;do touch $f.txt;done

[root@York ~]# ls

100.txt  16.txt  22.txt  29.txt  35.txt  41.txt  48.txt  54.txt  60.txt  67.txt  73.txt  7.txt   86.txt  92.txt  99.txt              wangwu.txt

10.txt   17.txt  23.txt  2.txt   36.txt  42.txt  49.txt  55.txt  61.txt  68.txt  74.txt  80.txt  87.txt  93.txt  9.txt               zhangsan.txt

11.txt   18.txt  24.txt  30.txt  37.txt  43.txt  4.txt   56.txt  62.txt  69.txt  75.txt  81.txt  88.txt  94.txt  anaconda-ks.cfg

12.txt   19.txt  25.txt  31.txt  38.txt  44.txt  50.txt  57.txt  63.txt  6.txt   76.txt  82.txt  89.txt  95.txt  install.log

13.txt   1.txt   26.txt  32.txt  39.txt  45.txt  51.txt  58.txt  64.txt  70.txt  77.txt  83.txt  8.txt   96.txt  install.log.syslog

14.txt   20.txt  27.txt  33.txt  3.txt   46.txt  52.txt  59.txt  65.txt  71.txt  78.txt  84.txt  90.txt  97.txt  li.txt

15.txt   21.txt  28.txt  34.txt  40.txt  47.txt  53.txt  5.txt   66.txt  72.txt  79.txt  85.txt  91.txt  98.txt

[root@York ~]#

向文件里面追加内容

[root@York data]# echo "I am study Linux...." > zhouyang.txt

[root@York data]# cat zhouyang.txt

I am study Linux....

[root@York data]#

注意: > 重定向

> 表示把文件里面的内容重置

>> 在原有的文件里面追加内容

或者使用 VI 编译器

多文本内容追加

[root@York ~]# cat  >>/data/zhouyang.txt<

> I am boy.

> Imiss you.

> EOF

[root@York ~]# cat /data/zhouyang.txt

I am study Linux....

I am boy.

Imiss you.

[root@York ~]#

拷贝一个文件到另一个目录下

[root@York ~]# cp /data/zhouyang.txt  /tmp/

[root@York ~]# cat /tmp/zhouyang.txt

I am study Linux....

I am boy.

Imiss you.

将一个data目录移动到ROOT 下

mv /data /root/

删除一个文件

rm zhouyang.txt文件

如果不需要提示

rm -f zhouyang.txt

删除一个目录

rm -fr data

把一个文件中I love you 不让他显示

[root@York data]# cat >>file.txt<

> I miss you

> I live you

> I thik you

> EOF

[root@York data]#

[root@York data]# grep -v thik file.txt

I miss you

I live you

[root@York data]# cat file.txt|grep -v "I miss you"

I live you

I thik you

[root@York data]

使用 grep -v thik file.txt  或者  cat file.txt|grep -v miss   过滤不需要的内容

head -2 file.txt 过滤掉 I thik you ;

在显示的时候删除I thik you

[root@York data]# sed  -e '/I thik you/d' file.txt

I miss you

I live you

sed  -e(相当于编辑) '/删除的内容/d' file.txt(连接删除的文件)

sed  -n(相当于取消默认的输出) /I love you/p file.txt

[root@York data]# cat >test.txt<

> list

> test

> miss

> EOF

[root@York data]# sed -n /miss/p test.txt

miss

[root@York data]#

输出除 miss 以外的字符

[root@York data]# sed  -n /[^miss]/p test.txt

list

test

[root@York data]#

list

test

Linux 三剑客

sed  awk grep

grep 擅长过滤

在 root目录下创建一个 /value/list/test 目录

[root@York ~]# mkdir -p /usr/local/value/list/test

[root@York ~]# ls

[root@York local]# tree /usr/local/value/

/usr/local/value/

└── list

└── test

2 directories, 0 files

[root@York local]#

在 /tmp 目录下创建一个 test.txt

/mnt 目录下创建一个 test.txt

把/tmp/test.txt 文件复制到 /mnt/test.txt路径下, 不显示提示

[root@York ~]# touch /mnt/test.txt

[root@York ~]# touch /ftp/test.txt

touch: 无法创建"/ftp/test.txt": 没有那个文件或目录

[root@York ~]# touch /tmp/test.txt

[root@York ~]# \cp -f /tmp/test.txt  /mnt/

[root@York ~]#

或者使用全路径

/bin/cp -f /tmp/test.txt  /mnt/

alias  别名

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值