Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2422589
  • 博文数量: 298
  • 博客积分: 7876
  • 博客等级: 准将
  • 技术积分: 5500
  • 用 户 组: 普通用户
  • 注册时间: 2011-02-23 13:39
文章存档

2013年(2)

2012年(142)

2011年(154)

分类: Python/Ruby

2012-04-25 23:30:22

目录

 (一)      文件相关. PAGEREF _Toc323325472 \h 1 08D0C9EA79F9BACE118C8200AA004BA90B02000000080000000E0000005F0054006F0063003300320033003300320035003400370032000000

1.     读取文件*.12的所有文件的第五到第七行. PAGEREF _Toc323325473 \h 1 08D0C9EA79F9BACE118C8200AA004BA90B02000000080000000E0000005F0054006F0063003300320033003300320035003400370033000000

2.     去掉root:home:tele:password中的root:home PAGEREF _Toc323325474 \h 1 08D0C9EA79F9BACE118C8200AA004BA90B02000000080000000E0000005F0054006F0063003300320033003300320035003400370034000000

3.     删除所有非字母开头的文件和文件夹. PAGEREF _Toc323325475 \h 1 08D0C9EA79F9BACE118C8200AA004BA90B02000000080000000E0000005F0054006F0063003300320033003300320035003400370035000000

4.     查找指定目录已经失效的软链接. PAGEREF _Toc323325476 \h 1 08D0C9EA79F9BACE118C8200AA004BA90B02000000080000000E0000005F0054006F0063003300320033003300320035003400370036000000

5.     查找指定目录已经失效的软链接并删除. PAGEREF _Toc323325477 \h 1 08D0C9EA79F9BACE118C8200AA004BA90B02000000080000000E0000005F0054006F0063003300320033003300320035003400370037000000

6.     复制除了path文件夹的文件和目录. PAGEREF _Toc323325478 \h 1 08D0C9EA79F9BACE118C8200AA004BA90B02000000080000000E0000005F0054006F0063003300320033003300320035003400370038000000

7.     删除以’-’开头的文件. PAGEREF _Toc323325479 \h 1 08D0C9EA79F9BACE118C8200AA004BA90B02000000080000000E0000005F0054006F0063003300320033003300320035003400370039000000

8.     grep匹配多行‘abc\nefg’. PAGEREF _Toc323325480 \h 1 08D0C9EA79F9BACE118C8200AA004BA90B02000000080000000E0000005F0054006F0063003300320033003300320035003400380030000000

9.     文件1中有的,文件2中没有(文件本身已排序). PAGEREF _Toc323325481 \h 2 08D0C9EA79F9BACE118C8200AA004BA90B02000000080000000E0000005F0054006F0063003300320033003300320035003400380031000000

10.    文件1中有的,文件2中没有(文件本身已排序). PAGEREF _Toc323325482 \h 2 08D0C9EA79F9BACE118C8200AA004BA90B02000000080000000E0000005F0054006F0063003300320033003300320035003400380032000000

11.    文件1文件2中都有的(文件本身已排序). PAGEREF _Toc323325483 \h 2 08D0C9EA79F9BACE118C8200AA004BA90B02000000080000000E0000005F0054006F0063003300320033003300320035003400380033000000

(二)      时间相关. PAGEREF _Toc323325484 \h 2 08D0C9EA79F9BACE118C8200AA004BA90B02000000080000000E0000005F0054006F0063003300320033003300320035003400380034000000

1.     获取一年前四个月后八天前的日期(GNU date. PAGEREF _Toc323325485 \h 2 08D0C9EA79F9BACE118C8200AA004BA90B02000000080000000E0000005F0054006F0063003300320033003300320035003400380035000000

2.     判断8位数的日期是否合法. PAGEREF _Toc323325486 \h 2 08D0C9EA79F9BACE118C8200AA004BA90B02000000080000000E0000005F0054006F0063003300320033003300320035003400380036000000

3.     crontab中的%字符. PAGEREF _Toc323325487 \h 2 08D0C9EA79F9BACE118C8200AA004BA90B02000000080000000E0000005F0054006F0063003300320033003300320035003400380037000000

(三)      目录相关. PAGEREF _Toc323325488 \h 2 08D0C9EA79F9BACE118C8200AA004BA90B02000000080000000E0000005F0054006F0063003300320033003300320035003400380038000000

1.     获取文件夹名/root/home (/root/home/tt.txt) PAGEREF _Toc323325489 \h 2 08D0C9EA79F9BACE118C8200AA004BA90B02000000080000000E0000005F0054006F0063003300320033003300320035003400380039000000

2.     获取文件名tt.txt (/root/home/tt.txt) PAGEREF _Toc323325490 \h 2 08D0C9EA79F9BACE118C8200AA004BA90B02000000080000000E0000005F0054006F0063003300320033003300320035003400390030000000

 

 

$ find . -name "*.12" -exec sed -n '5,7p;8q' {} >>filea \;

 

$ cut -d: -f2-  urfile

$ find . -mindepth 1 -name "[^a-zA-Z]*" | xargs -I {} rm -rf {}

$ find -L ur_path -type l

$ find -L ur_path -type l –delete

$find . -prune path1-maxdepth 1 -exec cp {} YYY \;

     rm - - -foo

rm ./-foo

匹配多行‘abc\nefg’

grep -A1 'abc$' filename | grep -B1 '^efg'

comm -23 file1 file2

comm -13 file1 file2

comm -12 file1 file2

12.    

 

后个月文件的第五到第七

#date -d"-1 year +4 month +8 day" +%Y-%m-%d

[[ `date -d'20101050' &>/dev/null` ]] && echo ok||echo no

中的%字符

crontab%字符被认为是换行,所以你的命令中有%时,在crontab中要加\转义

30 * * * * date '+%D' >datefile  

是错误的

正确的应该是

30 * * * * date '+\%D' >datefile

 

4.       

 

dirname path

basename path # basename path .txt 也去掉后缀

 

 

阅读(3265) | 评论(1) | 转发(3) |
0

上一篇:AWK相关积累

下一篇:SHELL相关积累

给主人留下些什么吧!~~