linux - 从文件中获取一行并将其附加到另一个文件

标签 linux bash

<分区>

我需要从文件中提取特定的行号,然后将其附加到另一个文件中。 bash 新手,请帮忙!

最佳答案

head -n<SkipLines> <filename> | tail -n<TakeLines>

所以如果你想从文件 pippo.txt 的第 10 行中提取 2 行:

head -n10 pippo.txt | tail -n2

编辑:

要将其附加到另一个文件,只需执行以下操作:

head -n<SkipLines> <filename> | tail -n<TakeLines> >> <OtherFile>

head -n10 pippo.txt | tail -n2 >> pippo2.txt

关于linux - 从文件中获取一行并将其附加到另一个文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37795519/

相关文章:

linux - Linux 上用户或进程之间的目录重新映射?

windows - 努力在 Windows 上构建 Gitea

bash - Linux : The command ls -la shows a file pointing to another file. 是什么意思?

bash - shell可以在 'command not found'之后运行特定的命令吗

linux - 在Nginx上服务外部文件

c - 什么(最小)C 图形库提供这些功能

linux - 在 Thunar 中远程创建自定义操作

linux - 如何在 Linux 服务器上渲染图形

linux - 从 bash 脚本中发送到后台的进程中检索退出代码

bash - 如何在 unix 终端模拟器中使用脚本命令?