var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: The grep command (HELP!!)
I'm trying to output any paragraph instance in a text file that a * occurs,
i've used the command cat filename.txt |grep -p '*'
but as * is a wildcard it throws out every paragraph in the file, and not just the ones that contain a *
Is there anyway of getting round this i.e by using a char code instead...?
Last edited by MultiD; 07-31-03 at 12:35.
Several lessons to be learnt here.
Firstly '*' is not a wildcard in this context, it is used to mean 'match 0 or many of the preceding character'. Thus:
a* would match a, aaaa or 'nothing'
aa* would match a, aaaa but would not match 'nothing'
[a-z]* would match a, zyxabc or 'nothing'
Secondly, why are you using cat? Grep will take a file as an argument so why cat it first?
grep "regex" yourFile
Finally (and the answer you are looking for), to escape the special meaning of a metacharacter (e.g. *-$), use the backslash '\\'
grep "\*" would match the '*' character
grep "\**" would match *, ******* and 'nothing'
Thanks Damian, I've learnt quite a bit from that