Chinaunix首页 | 论坛 | 博客
  • 博客访问: 54422
  • 博文数量: 28
  • 博客积分: 84
  • 博客等级: 民兵
  • 技术积分: 162
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-09 17:47
个人简介

try vuuv.github.io or somewhere else.

文章分类

全部博文(28)

文章存档

2013年(1)

2012年(5)

2011年(22)

我的朋友

分类:

2011-10-07 15:00:29

原文地址:find命令的格式化输出 作者:zooyo

  1. $ find . -type f
  2. ./aquota.user
  3. ./aquota.group
  4. ./file
  5. ./shells/killuser.sh
  6. ./shells/changeip.sh
  7. ./shells/delspace.sh

 

这样的查找很容易,也很方便,如果只想得到文件名,而去掉路径呢?

  1. find . -type f | awk -F'/' '{print $NF}

这样吗?NO!find命令本身就支持printf输出。

 

  1. $ find . -type f -printf "%f\n"
  2. aquota.user
  3. aquota.group
  4. file
  5. killuser.sh
  6. changeip.sh
  7. delspace.sh
是不是很神奇?好好man一下吧。还有%d目录层数,%s文件大小(字节)等等。
阅读(368) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~