说我有所谓的“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