Using find command in bash script

后端 未结 3 1645
旧巷少年郎
旧巷少年郎 2021-01-30 09:39

I just start to use bash script and i need to use find command with more than one file type.

list=$(find /home/user/Desktop -name \'*.pdf\') 

t

3条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-30 09:49

    If you want to loop over what you "find", you should use this:

    find . -type f -name '*.*' -print0 | while IFS= read -r -d '' file; do
        printf '%s\n' "$file"
    done
    

    Source: https://askubuntu.com/questions/343727/filenames-with-spaces-breaking-for-loop-find-command

提交回复
热议问题