如何不断的读取行 [英] How to incrementally read the lines
问题描述
我想编写一个脚本,从文件中读取行,其中符合重量^和p ^开始。
我能够得到的重量^但我无法才能计算P ^ ...
并有20重量^与对应的p ^现在我必须让各10重量^其对应的p ^在两个不同的文件,
我怎样才能做到这一点?
猫$(LS单位 - * - slides.txt |排序-n)| grep的ST ^|拆分-l 200
我在上面已经code使用
重量^等等等等
p ^等等等等等等等等
p ^等等等等等等等等
p ^等等等等等等等等
p ^等等等等等等等等
p ^等等等等等等等等等等等等
p ^等等等等等等等等等等等等等等等等
p ^等等等等等等等等等等等等
p ^等等等等等等等等等等等等
p ^等等等等等等等等等等等等
看来你之前一些空间p ^
。我复制你的pested例如,这grep的工作得很好的grep -E[] *(重量\\ ^ | P \\ ^)<文件>
它考虑到可能存在的空白的n个开始前行了。您可以附加的xargs
它
i want to write a script that reads lines from file where the line starts with wt^ and p^. i am able to get the wt^ but i am not able to get p^... and there are 20 wt^ with corresponding p^ now i have to get 10 each wt^ with its corresponding p^ in two different files,
how can i do this?
cat $( ls unit-*-slides.txt | sort -n ) | grep "st^" | split -l 200
i have used above code
wt^blah blah
p^blah blah blah blah
p^blah blah blah blah
p^blah blah blah blah
p^blah blah blah blah
p^blah blah blah blah blah blah
p^blah blah blah blah blah blah blah blah
p^blah blah blah blah blah blah
p^blah blah blah blah blah blah
p^blah blah blah blah blah blah
it seems you have some spaces before p^
. I copy pested your example and this grep worked fine
grep -E "[ ]*(wt\^|p\^)" <file>
it takes into account that there might be n number of whitespace before the beginning of the line. You can append xargs
with it
这篇关于如何不断的读取行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!