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 finegrep -E "[ ]*(wt\^|p\^)" <file>
it takes into account that there might be n number of whitespace before the beginning of the line. You can appendxargs
with itUse this regex
^(wt\^)|(p\^)
to match lines that being withwt^
orp^
Also from your post, it seems lines having
p^
have aspace
ortab
in the beginning, that may be a reason why your regex is not matching^p\^