How can I use xargs to copy files that have spaces and quotes in their names?

后端 未结 22 1160
春和景丽
春和景丽 2020-12-02 03:49

I\'m trying to copy a bunch of files below a directory and a number of the files have spaces and single-quotes in their names. When I try to string together find

22条回答
  •  鱼传尺愫
    2020-12-02 04:27

    I used Bill Star's answer slightly modified on Solaris:

    find . -mtime +2 | perl -pe 's{^}{\"};s{$}{\"}' > ~/output.file
    

    This will put quotes around each line. I didn't use the '-l' option although it probably would help.

    The file list I was going though might have '-', but not newlines. I haven't used the output file with any other commands as I want to review what was found before I just start massively deleting them via xargs.

提交回复
热议问题