Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to
LinuxQuestions.org , a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free.
Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please
contact us . If you need to reset your password,
click here .
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a
virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month.
Click here for more info.
07-30-2015, 09:14 AM
#1
Member
Registered: Aug 2008
Posts: 64
Rep:
grep wont work's
Hi,
I have a rtf file and I would like to match a pattern with grep but doesn't works. Maybe because is a rtf file?
The file have:
Code:
.....
\langfenp3082 {\rtlch\fcs1 \af0 \ltrch\fcs0
\cs17\lang1033\langfe3082\super\langnp1033\insrsid9076107\charrsid9076107 $}{\rtlch\fcs1 \af0 \ltrch\fcs0 \lang1033\langfe3082\langnp1033\insrsid9076107\charrsid9076107 }{\rtlch\fcs1 \af39 \ltrch\fcs0
\f39\lang1033\langfe3082\langnp1033\insrsid9076107\charrsid9076107 job_dataservices_0000}{\rtlch\fcs1 \af39 \ltrch\fcs0 \f39\lang1033\langfe3082\langnp1033\insrsid9076107 7}{\rtlch\fcs1 \af39 \ltrch\fcs0
If I do :
Code:
grep -i "\\ltrch\\fsc0" file.rtf
or
grep -i "\ltrch\fsc0" file.rtf
--
No ocurrences
could you help me?
Last edited by mierdatuti; 07-30-2015 at 09:19 AM .
07-30-2015, 09:19 AM
#2
LQ Guru
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313
grep worx for me:
Code:
[schneidz@hyper ~]$ cat mierdatuti.rtf
\langfenp3082 {\rtlch\fcs1 \af0 \ltrch\fcs0
\cs17\lang1033\langfe3082\super\langnp1033\insrsid9076107\charrsid9076107 $}{\rtlch\fcs1 \af0 \ltrch\fcs0 \lang1033\langfe3082\langnp1033\insrsid9076107\charrsid9076107 }{\rtlch\fcs1 \af39 \ltrch\fcs0
\f39\lang1033\langfe3082\langnp1033\insrsid9076107\charrsid9076107 job_dataservices_0000}{\rtlch\fcs1 \af39 \ltrch\fcs0 \f39\lang1033\langfe3082\langnp1033\insrsid9076107 7}{\rtlch\fcs1 \af39 \ltrch\fcs0
[schneidz@hyper ~]$ grep super mierdatuti.rtf
\cs17\lang1033\langfe3082\super\langnp1033\insrsid9076107\charrsid9076107 $}{\rtlch\fcs1 \af0 \ltrch\fcs0 \lang1033\langfe3082\langnp1033\insrsid9076107\charrsid9076107 }{\rtlch\fcs1 \af39 \ltrch\fcs0
07-30-2015, 09:20 AM
#3
Member
Registered: Aug 2008
Posts: 64
Original Poster
Rep:
Quote:
Originally Posted by
schneidz
grep worx for me:
Code:
[schneidz@hyper ~]$ cat mierdatuti.rtf
\langfenp3082 {\rtlch\fcs1 \af0 \ltrch\fcs0
\cs17\lang1033\langfe3082\super\langnp1033\insrsid9076107\charrsid9076107 $}{\rtlch\fcs1 \af0 \ltrch\fcs0 \lang1033\langfe3082\langnp1033\insrsid9076107\charrsid9076107 }{\rtlch\fcs1 \af39 \ltrch\fcs0
\f39\lang1033\langfe3082\langnp1033\insrsid9076107\charrsid9076107 job_dataservices_0000}{\rtlch\fcs1 \af39 \ltrch\fcs0 \f39\lang1033\langfe3082\langnp1033\insrsid9076107 7}{\rtlch\fcs1 \af39 \ltrch\fcs0
[schneidz@hyper ~]$ grep super mierdatuti.rtf
\cs17\lang1033\langfe3082\super\langnp1033\insrsid9076107\charrsid9076107 $}{\rtlch\fcs1 \af0 \ltrch\fcs0 \lang1033\langfe3082\langnp1033\insrsid9076107\charrsid9076107 }{\rtlch\fcs1 \af39 \ltrch\fcs0
I edit the main post
07-30-2015, 09:22 AM
#4
Senior Member
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,779
Quote:
Originally Posted by mierdatuti;5398324
[CODE
.....
\langfenp3082 {\rtlch\fcs1 \af0 \ltrch\
fcs0
\cs17\lang1033\langfe3082\super\langnp1033\insrsid9076107\charrsid9076107 $}{\rtlch\fcs1 \af0 \ltrch\fcs0 \lang1033\langfe3082\langnp1033\insrsid9076107\charrsid9076107 }{\rtlch\fcs1 \af39 \ltrch\fcs0
\f39\lang1033\langfe3082\langnp1033\insrsid9076107\charrsid9076107 job_dataservices_0000}{\rtlch\fcs1 \af39 \ltrch\fcs0 \f39\lang1033\langfe3082\langnp1033\insrsid9076107 7}{\rtlch\fcs1 \af39 \ltrch\fcs0 [/CODE]
If I do :
Code:
grep -i "\\ltrch\\fsc0 " file.rtf
or
grep -i "\ltrch\fsc0" file.rtf
--
One of these things is not like the other.
1 members found this post helpful.
07-30-2015, 09:27 AM
#5
LQ Guru
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313
Code:
[schneidz@hyper ~]$ grep -i '\\ltrch\\fcs0' mierdatuti.rtf
\langfenp3082 {\rtlch\fcs1 \af0 \ltrch\fcs0
\cs17\lang1033\langfe3082\super\langnp1033\insrsid9076107\charrsid9076107 $}{\rtlch\fcs1 \af0 \ltrch\fcs0 \lang1033\langfe3082\langnp1033\insrsid9076107\charrsid9076107 }{\rtlch\fcs1 \af39 \ltrch\fcs0
\f39\lang1033\langfe3082\langnp1033\insrsid9076107\charrsid9076107 job_dataservices_0000}{\rtlch\fcs1 \af39 \ltrch\fcs0 \f39\lang1033\langfe3082\langnp1033\insrsid9076107 7}{\rtlch\fcs1 \af39 \ltrch\fcs0
1 members found this post helpful.
07-30-2015, 09:45 AM
#6
Moderator
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Quote:
Originally Posted by
schneidz
Code:
[schneidz@hyper ~]$ grep -i '\\ltrch\\fcs0' mierdatuti.rtf
\langfenp3082 {\rtlch\fcs1 \af0 \ltrch\fcs0
\cs17\lang1033\langfe3082\super\langnp1033\insrsid9076107\charrsid9076107 $}{\rtlch\fcs1 \af0 \ltrch\fcs0 \lang1033\langfe3082\langnp1033\insrsid9076107\charrsid9076107 }{\rtlch\fcs1 \af39 \ltrch\fcs0
\f39\lang1033\langfe3082\langnp1033\insrsid9076107\charrsid9076107 job_dataservices_0000}{\rtlch\fcs1 \af39 \ltrch\fcs0 \f39\lang1033\langfe3082\langnp1033\insrsid9076107 7}{\rtlch\fcs1 \af39 \ltrch\fcs0
The subtle difference here is schneidz' use of single quotes versus double quotes around the regular expression.
I admittedly was a bit confused why that was posted, it almost seemed like a reiteration of the problem but it is an example of the solution.
07-30-2015, 10:45 AM
#7
Senior Member
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,863
\backslash\ is a special character for grep, so you have to duplicate it:
Code:
grep -i "\\\\ltrch\\\\fsc0" file.rtf
or
grep -i '\\ltrch\\fsc0' file.rtf
All times are GMT -5. The time now is 12:24 PM .
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know .
Latest Threads
LQ News