LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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


Reply
  Search this Thread
Old 07-30-2015, 09:14 AM   #1
mierdatuti
Member
 
Registered: Aug 2008
Posts: 64

Rep: Reputation: 15
Unhappy 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.
 
Old 07-30-2015, 09:19 AM   #2
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
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
 
Old 07-30-2015, 09:20 AM   #3
mierdatuti
Member
 
Registered: Aug 2008
Posts: 64

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by schneidz View Post
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
 
Old 07-30-2015, 09:22 AM   #4
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,779

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
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.
Old 07-30-2015, 09:27 AM   #5
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
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.
Old 07-30-2015, 09:45 AM   #6
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
Quote:
Originally Posted by schneidz View Post
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.
 
Old 07-30-2015, 10:45 AM   #7
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,863
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
\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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating an alias in ksh that uses grep and includes 'grep -v grep' doug248 Linux - Newbie 2 08-05-2012 02:07 PM
how does recursive grep work? serutan Linux - Newbie 5 07-11-2008 01:00 PM
wireless driver wont install,ethernet wont work Reanimator Linux - Newbie 4 05-05-2008 08:22 AM
ok got fglrx 2d to work, now why wont 3d work? bvav22 Linux - Software 1 05-01-2005 06:25 PM
FALCONS EYE (nethack) FAILS ON STARTUP, use to work, wont work even after reinstall roorings Linux - Software 0 10-08-2003 10:39 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:24 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration