Can you please tell me the meaning of .*
For eg. i have a text as "Scrapple the apple"
Now here, what does a.*e will match?
Can you please tell me the meaning of .*
For eg. i have a text as "Scrapple the apple"
Now here, what does a.*e will match?
It means "match any character, zero or more times, and be greedy about it". And for your text it will match "apple the apple"
But it is not working in my case
dsing1@[/export/home/dsing1] $ --> more exp
scrapple the apple
dsing1@[/export/home/dsing1] $ --> grep a.*e exp
scrapple the apple
Yes it is. grep returns the whole line if the regex is matching, not just the match.
so when i do a.*e then how will i get "apple the apple" from "scrapple the apple"
$ echo "scrapple the apple"|sed 's/s.*r//1'
apple the apple
Thanks
Sha
Just as a hint, for source, listings, command line examples, ... please use the tags (or the '#' symbol in the advanced editor), it's easier to read.
$ perl -pe 's/.*?(a.*e).*/$1/' exp
Other people can probably add more examples (awk anyone?)
echo 'scrapple the apple' | nawk '{for(i=1;i<=NF;i++) if($i ~ /a.*e/) printf("%s%c", $i, OFS); print ""}'