How can I generate a list of files with their absolute path in Linux?

后端 未结 21 2211
天涯浪人
天涯浪人 2020-11-28 16:56

I am writing a shell script that takes file paths as input.

For this reason, I need to generate recursive file listings with full paths. For example, the file

21条回答
  •  渐次进展
    2020-11-28 17:42

    Recursive files can be listed by many ways in linus. Here i am sharing one liner script to clear all logs of files(only files) from /var/log/ directory and second check recently which logs file has made an entry.

    First:-

    find /var/log/ -type f  #listing file recursively 
    

    Second:-

    for i in $(find $PWD -type f) ; do cat /dev/null > "$i" ; done #empty files recursively 
    

    Third use:-

    ls -ltr $(find /var/log/ -type f ) # listing file used in recent
    

    note: for directory location you can also pass $PWD instead of /var/log.

提交回复
热议问题