如何使用cat读取文件的第一行?
当前回答
你不用,用头代替。
head -n 1 file.txt
其他回答
有很多不同的方法:
sed -n 1p file
head -n 1 file
awk 'NR==1' file
使用下面的命令从CSV文件或任何文件格式中获取第一行。
head -1 FileName.csv
你不用,用头代替。
head -n 1 file.txt
你不需要猫。
head -1 file
会很好。
你可以使用cat file.txt | head -1,但是直接使用head可能更好,就像在head -1 file.txt中那样。