I have the necessity to use this command:
cat file1 | grep $A | grep $B
where sometime A and, or, B are not set.
For example:
I set A=@
never defined or set B
The above command send a cat error.
Any idea?
Thanks.
Giovanni
I have the necessity to use this command:
cat file1 | grep $A | grep $B
where sometime A and, or, B are not set.
For example:
I set A=@
never defined or set B
The above command send a cat error.
Any idea?
Thanks.
Giovanni
2 things.
check out egrep.
cat file|egrep $A\|$B
when you declare $A or $B if you use a meta charicter make sure you backslash it to remove its special meaning.
[qgatu003]/export/home/mxdooley$cat test.file|egrep $A\|$B
@this is a test2
[qgatu003]/export/home/mxdooley$echo $A
@
[qgatu003]/export/home/mxdooley$