linux 合集

1 查找某个目录下的所有的某类型的文件(如script文件)

ls | file -f - | grep script

2 比较两个目录结构(不比具体内容)

ls -R directory1 > directory1.txt
ls -R directory2 > directory2.txt
diff -y –suppress-common-lines directory1.txt directory2.txt
如果给ls加上“-1s”的选项(注意:是1,2,3的1,不是l,m,n的l),还可以比较文件的大小。

3 压缩与解压

 tar -zcvf name.tar.gz files-or-directory

 tar -cvf name.tar files-or-directory

 tar -zxvf name.tar.gz

注:无z(gz)j(bz2)则只打包不压缩

4 将bash输出同时定向到文件和屏幕

如:ls | tee out.txt

ls | tee out.txt | less


6 free:查看内存

7 linux中在多个文件中查找某个内容并替换

ls my.cnf.200* |xargs grep "21820000" -R | awk -F: '{print $1}' |  sort | uniq | xargs sed -i 's/server_id=[0-9]\+/server_id=21820000/g'

8 我的alias设置

alias c='clear' \nalias llh='ll -h' \nalias lla='ll -a' \nalias cdh='cd ~/hisin' \nalias rm='/usr/bin/perl /home/mysql/hisin/myprogram/bin/rm.pl' \nalias lsrm='ls -a /home/mysql/hisin/.trash_hisin/' \nalias llrm='ll -atrlh /home/mysql/hisin/.trash_hisin/' \nalias cdrm='cd /home/mysql/hisin/.trash_hisin' \n

9 按大小查找文件
find ./ -size +10M -print |xargs ls -lh
10 删选日志文件-打印特定列-去重-移入临时文件夹
cat monitor_tokudb_file.log |grep diff | awk '{printf("%s\n%s\n",$2,$3)}'|sort|sort|uniq | xargs -I {} mv {} tardir
11 find 使用的几个常用选项
find dir -maxdepth 2 -iname "one*two*" -min +1440(-mtime +1)
12 linux: command not found
which command看命令是否真的存在,然后指定默认值试试。

13. 删除文件名带空格的文件

find .|grep aaa|xargs -I {} rm {}


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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值