zoukankan      html  css  js  c++  java
  • linux find命令使用

    Find is a very strong command to search for files and folders. You can search for files based on certain criteria besides filename, such as file types, atime, belongs to which groups, file modes, etc. Because find command support a lots of options, therefore sometimes find command line looks very complicated, but actually it is not. Don’t let the lengthy find command lines scares you away, find can be very easy to use.

    You just need to ask yourself 3 question?
    1. What is the path you want to begin your search from? current directory.
    2. What is the filename you want to search? any files with keyword ‘love’
    3. What is the file types? normal file

    Okay, lets construct the simple find command line.

    find . -name "*love*" -type f

    1. Current directory can be write as a single dot (.)
    2. Specified the filename by option -name and you can use wildcard to construct your keyword.
    3. Use -type to force your file type for accuracy search result, but you can ignore specifying the -type.
    ( check out -type in man page for more info)

    Do you want to know more?

    I want to manipulate the result of find. Let say I want to find all wave files in a specific folder, and I want to know the file info of each wave file. Lets construct the find command line:

    find ~/uc/dump -name "*.wav" -exec file {} \;

    It start to looks complicated, but it is quite straight forward, -exec means execute, file are the command i use to check the file info, {} indicate the find’s result, \; is something I don’t understand, but have to be there. \; probably are use to separate each find’s result, i guess.

    Do you want more? I want to find all my documents with extension .pdf and .chm, how do I construct my find command line.

    find /home/hkong/documents/ -name "*.pdf" -or -name "*.chm"

    With using -or, you can specify your more than one keywords as file name. This is very useful, we usually execute find twice for different keywords, actually we can do this in one line.

    Do you have any interesting find tips to share with us?

  • 相关阅读:
    本地向GitHub提交403错误解决办法(自己的创建的项目)
    zepto-ajax跨域请求接口 jsonp 静态页面数据展示
    自定义获取url方法
    使用swiper 轮播插件ajax 请求加载图片时,无法滑动问题
    背景透明,文字不透明解决办法
    js DOM Element属性和方法整理----转载
    图像处理作业5——SIFT算法与全景图像生成
    应用连续高斯模糊后得到的σ是多少?
    Pandas学习笔记——综合练习
    Pandas学习笔记5——合并
  • 原文地址:https://www.cnblogs.com/welkinwalker/p/1955937.html
Copyright © 2011-2022 走看看