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

后端 未结 9 963
[愿得一人]
[愿得一人] 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:23

        find . | sed "s|.*|\"&\"|"
    

    Brief description:
    We take result of .* pattern and put it into quotes.
    Good source is sed.

    Detail description:
    Pattern: s/one/ONE/

    • s Substitute command.
    • / Delimiter.
      In my expression "|" is used instead of "/" to prevent "mountains" like in pattern s/.*/\"&\"/.
    • one Regular expression pattern search pattern.
    • ONE Replacement string.
    • .* Means any symbol that repeats unlimited number of times.
    • \" Means " itself.
    • & Special character that corresponds to the pattern found.

提交回复
热议问题