Iterate over a list of files with spaces

前端 未结 11 1613
-上瘾入骨i
-上瘾入骨i 2020-11-22 05:16

I want to iterate over a list of files. This list is the result of a find command, so I came up with:

getlist() {
  for f in $(find . -iname \"f         


        
11条回答
  •  自闭症患者
    2020-11-22 06:04

    In some cases, here if you just need to copy or move a list of files, you could pipe that list to awk as well.
    Important the \"" "\" around the field $0 (in short your files, one line-list = one file).

    find . -iname "foo*" | awk '{print "mv \""$0"\" ./MyDir2" | "sh" }'
    

提交回复
热议问题