string manipulation
suppose i want to find a pattern with grep, sed or awk,is there any way by which i can print what is in the right hand side of that pattern till the end of the line.
|
Code:
>cat file Is this your question? |
more correctly:
Code:
sed -e 's/.*pattern//' |
okay let me try them and i will inform that.
what if i want to print the info between 2 words/patterns. e.g. let the following line exists in a file. this is pattern1 and this is pattern2. if i want to pring between pattern1 and pattern2 i.e. "and this is" then how to do it? |
sed -e 's/.*pattern1\(.*\)pattern2.*/\1/'
should do it or, same amount of typing perl -pe 's/.*pattern1(.*)pattern2.*/$1/' |
Code:
echo "this is pattern1 and this is pattern2" | sed -e 's/.*pattern1//;s/pattern2//' |
Why do people always type the -e option when they're only using a single command? Must like typing, I guess.;)
|
All times are GMT -5. The time now is 09:35 PM. |