Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个包含数百万个文件的目录。我刚刚了解到数百万人是孤儿,我需要取消他们的联系。我想从单个文本文件(理想情况下为 csv)中的所有文件数组开始。你能帮我吗?
我打算做一个ls并将终端输出保存到一个文件中,但我认为有一种更优雅的方式。
ls
我怎样才能使ls > log.csv最终看起来像
ls > log.csv
file1.txt,file2.txt, ... fileN.txt?
file1.txt,file2.txt, ... fileN.txt
尝试这样做:
printf '%s\n' *.txt | paste -sd "," - > log.csv
或者
printf '%s,' *.txt > log.csv
printf '"%s",' *.txt > log.csv
如果文件名中有空格等特殊字符。