說我有所謂的「demo.txt」的文本文件誰是這樣的:如何從bash中的文本文件讀取第n行?
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
現在我想讀某行,說行2,用一個命令,這將是這個樣子:
Line2 = read 2 "demo.txt"
所以,當我會打印:
echo "$Line2"
我會得到:
5 6 7 8
我知道如何使用'sed'命令來打印文件中的第n行,但不知道如何讀取它。我也知道'閱讀'命令,但不知道如何使用它以確定某一行。
在此先感謝您的幫助。
[bash工具從文件中獲得第n行]的可能重複(http://stackoverflow.com/questions/6022384/bash-tool-to-get-nth-line-from-a-file) – tripleee 2014-11-21 11:05:36