LinuxAnswers - the LQ Linux tutorial section.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 12-27-2007, 12:34 AM   #1
Registered: Oct 2007
Posts: 160

Rep: Reputation: 30
Question grep '^[^1]' h.txt (what does the " ' " character indicate

i have searched many sites for regular expressions. they all ignore to tell about one character. what does the " ' " (single quotes) signify.

such as in the following example .

grep '^[^1]' h.txt

does they have special meaning or it is a syntax( for linux commands).
Old 12-27-2007, 07:32 AM   #2
LQ Newbie
Registered: Dec 2007
Location: Prince Edward Island
Distribution: Debian Etch
Posts: 17

Rep: Reputation: 0
The single quote is an alternate quote character. More of a strict quote. Can be used to encase literal double-quotes, instead of escaping them.

sed "s/\(abcd\"abcd\)/\1/g"
Out - abcd"abcd

sed 's/\(abcd"abcd\)/\1/g'
Out - abcd"abcd
Old 12-27-2007, 07:51 AM   #3
Registered: Sep 2006
Location: Munich, Germany
Distribution: Debian / Ubuntu
Posts: 297

Rep: Reputation: 49
Originally Posted by babu198649 View Post

grep '^[^1]' h.txt
Those quotes are interpreted by the shell, not grep. grep never sees those quotes.
Old 12-28-2007, 04:50 AM   #4
Registered: Oct 2007
Posts: 160

Original Poster
Rep: Reputation: 30
thank u ..........
Old 12-29-2007, 11:32 AM   #5
Senior Member
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 232Reputation: 232Reputation: 232
That sed command can get even cleaner:
sed -r 's/(abcd"abcd)/\1/g'
and prettier:
sed -r 's,(abcd"abcd),\1,g'

As for the single quotes, they are telling the shell not to interpret anything found between them, & to pass the enclosed argument(s) to grep, sed, or whatever.

If you want to pass the value (as opposed to its literal name) of a shell to a program, then use the double quotes.

It is a good habit, rarely a mistake, to enclose the regex passed to grep in single quotes.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Txt Edr.- HTML- Custom Saved Code "Snippets" WhatsOnYourBrain Linux - Software 1 04-01-2007 04:36 PM
Removing "#" character in a huge txt file tmaxx Linux - General 3 10-24-2006 04:04 AM
where is "installed-chrome.txt" file in firefox 1.5 ?? tuxfood Linux - Software 1 12-21-2005 01:44 PM
cannot exit normally after "nohup blablabla > output.txt &" LQYY Linux - Newbie 1 12-14-2004 11:02 AM
"Undeleting" data using grep, but get "grep: memory exhausted" error SammyK Linux - Software 2 03-13-2004 04:11 PM

All times are GMT -5. The time now is 09:16 AM.

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