The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Regex in grep to match all lines ending with a double quote (") OR a single quote (') NanJ Shell Programming and Scripting 6 08-26-2009 10:28 AM
how to print single quote in awk gauravgoel UNIX for Dummies Questions & Answers 6 08-20-2008 05:48 PM
escaping single quote javeed7 Shell Programming and Scripting 3 04-02-2008 06:36 AM
single quote dreams5617 Shell Programming and Scripting 2 12-01-2007 03:37 AM
Replacing a single quote rjsha1 Shell Programming and Scripting 3 12-23-2005 10:55 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 4 Weeks Ago
cimcmahon cimcmahon is offline
Registered User
  
 

Join Date: Nov 2009
Posts: 4
grep : having trouble with a single quote

Hi,
I search for the string below which contains a single quote,
some text '/home/myuser
in the file myfile.txt as another user with the grep command as follows
su - myuser -c "grep 'some text \'/home/myuser' myfile.txt"

I also tried using two backslashes
su - myuser -c "grep 'some text \\'/home/myuser' myfile.txt"
but to no avail, I still get
Unmatched '.
Does anyone have a solution for this silly problem?

Thanks,
C
  #2 (permalink)  
Old 4 Weeks Ago
durden_tyler's Avatar
durden_tyler durden_tyler is online now Forum Advisor  
Registered User
  
 

Join Date: Apr 2009
Posts: 547
Try this (not tested):


Code:
su - myuser -c "grep \"some text '/home/myuser\" myfile.txt"

tyler_durden



  #3 (permalink)  
Old 4 Weeks Ago
cimcmahon cimcmahon is offline
Registered User
  
 

Join Date: Nov 2009
Posts: 4
Hi there,
Thanks for your suggested solution.
Unfortunately I get the same outcome
su - d3dadm -c "grep \"successfully loaded DB2 library '/db2/db2\" trans.log"
Unmatched '.
Regards,
C
  #4 (permalink)  
Old 4 Weeks Ago
durden_tyler's Avatar
durden_tyler durden_tyler is online now Forum Advisor  
Registered User
  
 

Join Date: Apr 2009
Posts: 547
Quote:
Originally Posted by cimcmahon View Post
...
Unfortunately I get the same outcome
su - d3dadm -c "grep \"successfully loaded DB2 library '/db2/db2\" trans.log"
Unmatched '.
...
What shell ?

tyler_durden
  #5 (permalink)  
Old 4 Weeks Ago
cimcmahon cimcmahon is offline
Registered User
  
 

Join Date: Nov 2009
Posts: 4
Hi tyler,
I found out the answer if anyone is interested
su - d3dadm -c "grep "\"successfully loaded DB2 library \'/db2/db2d3d\"" trans.log"
I only ever use csh for scripts as its nearly always guaranteed to be on all machines.
Thanks,
C
  #6 (permalink)  
Old 4 Weeks Ago
protocomm protocomm is offline
Registered User
  
 

Join Date: Mar 2009
Location: france, montpellier
Posts: 150
I try this, and it's work...on bash


Code:
grep "some text '/home/myuser" file

  #7 (permalink)  
Old 4 Weeks Ago
cimcmahon cimcmahon is offline
Registered User
  
 

Join Date: Nov 2009
Posts: 4
Hi,
You didn't su - user,
so it's not working.
Thanks,
C
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:27 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0