Perl:从1到n提取行(Windows) [英] Perl: extract rows from 1 to n (Windows)
本文介绍了Perl:从1到n提取行(Windows)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从我的.csv文件中提取第1到第n行。使用此
I want to extract rows 1 to n from my .csv file. Using this
perl -ne 'if ($. == 3) {print;exit}' infile.txt
我只能提取一行。如何将一系列行放入此脚本?
I can extract only one row. How to put a range of rows into this script?
推荐答案
出现了什么问题:
head -3 infile.txt
你真的必须使用Perl,然后这个工作:
If you really must use Perl then this works:
perl -ne 'if ($. <= 3) {print} else {exit}' infile.txt
这篇关于Perl:从1到n提取行(Windows)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文