linux批量,linux 批量操作 方法

[zhang@localhost begnning_linux_proggramming]$ ls

780470147627-code-ch01.tgz 780470147627-code-ch06.tgz 780470147627-code-ch11.tgz 780470147627-code-ch16.tar.gz temp.sh

780470147627-code-ch02.tgz 780470147627-code-ch07.tgz 780470147627-code-ch12.tgz 780470147627-code-ch17.tar.gz

780470147627-code-ch03.tgz 780470147627-code-ch08.tgz 780470147627-code-ch13.tgz ReadMe.txt

780470147627-code-ch04.tgz 780470147627-code-ch09.tgz 780470147627-code-ch14.tgz

780470147627-code-ch05.tgz 780470147627-code-ch10.tgz 780470147627-code-ch15.tgz[zhang@localhost begnning_linux_proggramming]$[zhang@localhost begnning_linux_proggramming]$ for i in `ls *.tgz`; do echo tar zxvf $i; done;

tar zxvf 780470147627-code-ch01.tgz

tar zxvf 780470147627-code-ch02.tgz

tar zxvf 780470147627-code-ch03.tgz

tar zxvf 780470147627-code-ch04.tgz

tar zxvf 780470147627-code-ch05.tgz

tar zxvf 780470147627-code-ch06.tgz

tar zxvf 780470147627-code-ch07.tgz

tar zxvf 780470147627-code-ch08.tgz

tar zxvf 780470147627-code-ch09.tgz

tar zxvf 780470147627-code-ch10.tgz

tar zxvf 780470147627-code-ch11.tgz

tar zxvf 780470147627-code-ch12.tgz

tar zxvf 780470147627-code-ch13.tgz

tar zxvf 780470147627-code-ch14.tgz

tar zxvf 780470147627-code-ch15.tgz[zhang@localhost begnning_linux_proggramming]$

一次性解压:

[zhang@localhost begnning_linux_proggramming]$ for i in `ls *.tgz`; do tar zxvf $i; done

chapter01/

chapter01/bill.c

chapter01/lib.h

chapter01/program.c

chapter01/hello.c

chapter01/fred.c

ch02/

ch02/app/

ch02/app/cd_db

ch02/app/title.cdb

ch02/app/tracks.cdb

ch02/case1chapter15/server4.c

chapter15/client2.c

chapter15/server2.c

chapter15/Makefile

[zhang@localhost begnning_linux_proggramming]$

[zhang@localhost begnning_linux_proggramming]$2. 批量文件重命名

[zhang@localhost begnning_linux_proggramming]$ ls

780470147627-code-ch01.tgz 780470147627-code-ch07.tgz 780470147627-code-ch13.tgz ch06 ch14 chapter11

780470147627-code-ch02.tgz 780470147627-code-ch08.tgz 780470147627-code-ch14.tgz ch07 chapter01 chapter15

780470147627-code-ch03.tgz 780470147627-code-ch09.tgz 780470147627-code-ch15.tgz ch08 chapter03 ReadMe.txt

780470147627-code-ch04.tgz 780470147627-code-ch10.tgz 780470147627-code-ch16.tar.gz ch09 chapter04 temp.sh

780470147627-code-ch05.tgz 780470147627-code-ch11.tgz 780470147627-code-ch17.tar.gz ch12 chapter05

780470147627-code-ch06.tgz 780470147627-code-ch12.tgz ch02 ch13 chapter10

[zhang@localhost begnning_linux_proggramming]$

[zhang@localhost begnning_linux_proggramming]$

[zhang@localhost begnning_linux_proggramming]$ rename chapter ch chapter??

[zhang@localhost begnning_linux_proggramming]$ ls

780470147627-code-ch01.tgz 780470147627-code-ch06.tgz 780470147627-code-ch11.tgz 780470147627-code-ch16.tar.gz ch04 ch09 ch14

780470147627-code-ch02.tgz 780470147627-code-ch07.tgz 780470147627-code-ch12.tgz 780470147627-code-ch17.tar.gz ch05 ch10 ch15

780470147627-code-ch03.tgz 780470147627-code-ch08.tgz 780470147627-code-ch13.tgz ch01 ch06 ch11 ReadMe.txt

780470147627-code-ch04.tgz 780470147627-code-ch09.tgz 780470147627-code-ch14.tgz ch02 ch07 ch12 temp.sh

780470147627-code-ch05.tgz 780470147627-code-ch10.tgz 780470147627-code-ch15.tgz ch03 ch08 ch13

[zhang@localhost begnning_linux_proggramming]$

[zhang@localhost begnning_linux_proggramming]$

[zhang@localhost begnning_linux_proggramming]$ ls alltgz ch02 ch04 ch06 ch08 ch10 ch12 ch14 chap16_src ReadMe.txt ch01 ch03 ch05 ch07 ch09 ch11 ch13 ch15 chap17_src temp.sh [zhang@localhost begnning_linux_proggramming]$ [zhang@localhost begnning_linux_proggramming]$ rename chap ch chap*[zhang@localhost begnning_linux_proggramming]$ lsalltgz  ch02  ch04  ch06  ch08  ch10  ch12  ch14  ch16_src  ReadMe.txtch01    ch03  ch05  ch07  ch09  ch11  ch13  ch15  ch17_src  temp.sh[zhang@localhost begnning_linux_proggramming]$

3.vim 下下批量删除/替换

命令模式下 批量删除 ^M (Windows 把\r\n 而不是 \n 作为换行符)

:%s/^M//gc

等价为

:%s/\r//gc

^M 即 \r 输入为 ctrl + v, ctrl + mg选项表示全局替换,c选项表示每次替换都需要确认。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值