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

后端 未结 21 2208
天涯浪人
天涯浪人 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:45

    Most if not all of the suggested methods result in paths that cannot be used directly in some other terminal command if the path contains spaces. Ideally the results will have slashes prepended. This works for me on macOS:

    find / -iname "*SEARCH TERM spaces are okay*" -print 2>&1  | grep -v denied |grep -v permitted |sed -E 's/\ /\\ /g'
    

提交回复
热议问题