![](/img/trans.png)
[英]How can I copy/paste text from one Vim file to another Vim file in another shell tab?
[英]Copy/Paste part of a file into another file using Terminal (or Shell)
我试图将.txt文件的一部分从行号n复制到行号n + y(假设1000到1000000)。
我试过运营商和sed ,但它失败了。 这是我试过的命令:
sed -n "1000, 1000000p" path/first/file > path/second/file
如果您知道源文件(wc -l)中有多少行,则可以执行此操作。假设12000行,并且您希望新文件中的行2000 - 7000(总共5000行)。
cat myfile | 尾巴-10000 | head -5000> newfile
读取最后10k行,然后读取第1行5k行。
sed
命令应该可以正常工作,用单引号替换双引号。
sed -n '1000, 1000000p' path/first/file > path/second/file
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.