[英]Is there a linux command loop through files in a directory then write all files names and content into csv file?
I have a directory with 100 thousand files (each file has only one line), I need a fast way to go through all files to write one csv file that contains two columns: File Name, Content of the File.我有一个包含 10 万个文件的目录(每个文件只有一行),我需要一种快速浏览所有文件的方法来编写一个包含两列的 csv 文件:文件名、文件内容。
File_A: This is File one. File_A:这是文件一。
File_B: This is file two. File_B:这是文件二。
I need to get a csv file: File_A This is File one.我需要得到一个 csv 文件: File_A 这是文件一。 File_B This is file two.
File_B 这是文件二。
Just do grep . * > ../output.csv
只是做
grep . * > ../output.csv
grep . * > ../output.csv
to create a file with a :
separator. grep . * > ../output.csv
创建一个带有:
分隔符的文件。 If you want to use a different delimiter, pipe it to sed
.如果要使用不同的分隔符,请将其通过管道传输到
sed
。 Some grep provide a --null
option to use a zero byte as the delimiter.某些 grep 提供了一个
--null
选项来使用零字节作为分隔符。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.