how to output file names surrounded with quotes in SINGLE line?

后端 未结 9 956
[愿得一人]
[愿得一人] 2021-02-03 19:47

I would like to output the list of items in a folder in the folowing way:

\"filename1\"  \"filename2\" \"file name with spaces\" \"foldername\" \"folder name wit         


        
9条回答
  •  梦谈多话
    2021-02-03 20:35

    this should work

    find $PWD | sed 's/^/"/g' | sed 's/$/"/g' | tr '\n' ' '
    

    EDIT:

    This should be more efficient than the previous one.

    find $PWD | sed -e 's/^/"/g' -e 's/$/"/g' | tr '\n' ' '
    

    @Timofey's solution would work with a tr in the end, and should be the most efficient.

    find $PWD -exec echo -n '"{}" ' \; | tr '\n' ' '
    

提交回复
热议问题