cat in linux, file holding special charcters

Hi
I'd like to cat, in linux, a file that holds special charcters, like "-->" and ">" and "]"
For example I have a file named test123.txt
it looks like this:
2008-09-11 00:27:01,496 -
< 0 > --> Start calculation of pattern [PROCESS_complex3], Pattern was split to [1] pattern graphs
< 0 > System Tqls Optimizer going to ask System Tqls results for all graph's elements except [-13]
< 16 > System Tqls Optimizer got System tqls results for [-11]
< 16 > Entered OverallPatternGraphCalculator witks [2] ; -15(-11 --> -13) - container_f ; -19(-11 --> -17) - container_f] calculation size [0 consistent=true]
< 16 > Entered ComponentGraphCalculator with component [Num of nodes [3] ; -17 - process ; -13 - disk ; -11 - host Num of links [2] ; -15(-11 --> -13) - container_f ; -19(-11 --> -17) - container_f, elements size 0] calculation size [0 consistent=true]
< 16 > Entered CompositeCalcul [2] ; -15(-11 --> -13) - container_f ; -19(-11 --> -17) - container_f, elements size 0] calculation size [0 consistent=true]
< 7500 > Calculation ended, result size [1769 consistent=false]
< 7500 > Calculation ended, result size [1769 consistent=false]
< 7500 > Entered ConsistencyChe- process ; -13 - disk ; -11 - host Num of links [2] ; -15(-11 --> -13) - container_f ; -19(-11 --> -17) - container_f] calculation size [1769 consistent=false]
< 7500 > Consistency at pattern level was found to be required due to previous calculation inconsistency
< 7516 > Calculation ended, result size [1769 consistent=false]
< 7516 > Calculation ended, result size [1769 consistent=false]
< 7516 > Result size [1769]
I want to cat it, the result should be:
< 0 > --> Start calculation of pattern [PROCESS_complex3], Pattern was split to [1] pattern graphs
< 7516 > Result size [1769]
I tried varations of the following command:
cat test123.txt | grep "> --> Start calculation of pattern [" | grep "> Result size ["
I tried it with one '
and with \ before the special chars etc...
Any Ideas ?
Thanks :slight_smile:

grep -e 'Start calculation of pattern' -e 'Result size' file.txt

You do not need cat, grep -e can search for multiple patterns, and you can sometimes find unique pattern identifiers that do not use metacharacters.

Thanks jim :slight_smile:

I need to know how can I include special chars like: < > [ ] -- etc..
cause I need to look fo the exact line "> --> Start calculation of pattern "
the line "Start calculation of pattern" can appear in other places

Hope this helps:

grep -E '(<.*Start calculation|<.*Result size)' file.txt

Other sepcial characters are escaped with a backslash \ this prevents grep or sed from turning the character into a metacharacter

Thanks Jim :slight_smile:
It's working