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.
想知道如何在 unix 中打印/获取文本文件中的第一个字符。
即说“9 textfile.txt”将返回 9
谢谢
您可以使用head获取文件的第一个字符:
head
head -c 1 file.txt
如果你想要每行的第一个字符:
grep -o ^. file.txt
或者
cut -c 1 file.txt