LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-23-2015, 06:30 AM   #1
ChristinaCann
LQ Newbie
 
Registered: Feb 2015
Posts: 1

Rep: Reputation: Disabled
using grep to find text ending with apostrophe


Help!

I have an assignment question where I have to grep an expression which will find the name 'Name' as well as 'name's".

I went through the listed comments for apostrophe, but I wasn't successful.

Any ideas?

Last edited by ChristinaCann; 02-23-2015 at 07:18 AM. Reason: Used full assg question
 
Old 02-23-2015, 07:03 AM   #2
linosaurusroot
Member
 
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 982
Blog Entries: 2

Rep: Reputation: 244Reputation: 244Reputation: 244
http://www.linuxquestions.org/linux/rules.html

Do not post homework assignments verbatim. We're happy to assist if you have specific questions or have hit a stumbling point, however. Let us know what you've already tried and what references you have used (including class notes, books, and searches) and we'll do our best to help. Keep in mind that your instructor might also be an LQ member.
 
Old 02-23-2015, 07:35 AM   #3
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 3,341

Rep: Reputation: Disabled
Quote:
Originally Posted by ChristinaCann View Post
I have an assignment question where I have to grep an expression which will find the name 'Name' as well as 'name's".

I went through the listed comments for apostrophe, but I wasn't successful.
The apostrophe is one of several characters that have special meaning in the shell environment, so in order to be interpreted literally, it must be "escaped" by another special character, the backslash.

Last edited by Ser Olmy; 02-23-2015 at 08:45 AM.
 
Old 02-23-2015, 08:07 AM   #4
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,371

Rep: Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750
Quote:
it must be "escaped" by another special character, the backspace.
Er, small typo there. Methinks that should read backslash, not backspace.
 
Old 02-23-2015, 08:46 AM   #5
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 3,341

Rep: Reputation: Disabled
Quote:
Originally Posted by allend View Post
Er, small typo there. Methinks that should read backslash, not backspace.
Absolutely, thanks for pointing that out. I've corrected the post accordingly.

Although you must admit that using backspace will eliminate any issues one might experience if a command line argument contains apostrophes.
 
Old 02-23-2015, 08:55 AM   #6
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,371

Rep: Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750
Absolutely admitted.
 
Old 02-23-2015, 09:01 AM   #7
Miati
Member
 
Registered: Dec 2014
Distribution: Linux Mint 17.*
Posts: 326

Rep: Reputation: 106Reputation: 106
I would suggest reading through the man pages of grep.
To help, you're looking for something that would probably ignore case (name versus Name) and/or searches that can include multiple search patterns (Name' or name's)
 
  


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
using grep to find text sections lapishater276 Linux - Newbie 5 07-17-2014 07:17 AM
using find or grep to find a group of text strings. tkmsr Linux - Newbie 3 03-04-2011 07:02 AM
grep searching for strings with '(apostrophe) macsdev Programming 5 11-11-2010 11:46 PM
Can I use GREP to find & replace text? jim.thornton Linux - Newbie 3 07-18-2008 06:36 PM
GREP - reg exp to find words ending with .V and .TO vikram_cvk Linux - Server 5 12-22-2006 01:47 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:31 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