I need some help from the wise-guys of Arizona.

sean sean.a.ritzler at gmail.com
Sat Mar 7 08:43:38 MST 2015


$ matches the end of line. You don't get any output because that file
doesn't have any lines ending in 'bmike1'. That's why it was recommended
that you grep for a shell.

You are getting the same output with and without the ^ because it happens
to be that bmike1 always appears at the beginning of the line in that file.
Create a new file with these two lines:

My name is bmike1
bmike1 is my name

Then do grep ^bmike1, grep bmike1 and just grep bmike1 (no -E necessary).
On Mar 7, 2015 8:34 AM, "Michael Havens" <bmike1 at gmail.com> wrote:

> Okay, I tried to grep my passwd file with and without the '^' and it seems
> both are the same. What's the difference between the commands and why
> should I bother to type the '^'? As to the '$' if all it does is produces a
> blank linr what is it's use?
>
> bmike1 at c521 ~ $ grep -E '^bmike1:' /etc/passwd
> bmike1:x:1000:1000:Michael Havens,,,:/home/bmike1:/bin/bash
> bmike1 at c521 ~ $ grep -E 'bmike1:' /etc/passwd
> bmike1:x:1000:1000:Michael Havens,,,:/home/bmike1:/bin/bash
> bmike1 at c521 ~ $ grep -E 'bmike1$:' /etc/passwd
> bmike1 at c521 ~ $ grep -E 'bmike1$' /etc/passwd
> bmike1 at c521 ~ $
>
>
> :-)~MIKE~(-:
>
> On Fri, Mar 6, 2015 at 11:39 PM, der.hans <PLUGd at lufthans.com> wrote:
>
>> Am 06. Mär, 2015 schwätzte Michael Havens so:
>>
>> moin moin Mike,
>>
>> when using regular expressions '$' matches the end of the line and '^'
>> matcheѕ the beginning of the line. So, '^$' matches a blank line.
>>
>> grep -E '^fred:' /etc/passwd # shows the entry for fred's account
>>
>> grep -E ':/bin/bash$' /etc/passwd # shows all of the accounts that have
>> bash as their shell
>>
>> ciao,
>>
>> der.hans
>>
>>
>>  I'm going through the BASH manual at The Linux Documentation Project and
>>> was going over special characters. They say that 'a "$" addresses the end
>>> of a line bash'. Huh; what does that mean? You see on my blog that I had
>>> another special character I was wondering about but my web search
>>> revealed
>>> to me what was hidden. My web search in this case turns up a lot of stuff
>>> too. None of it relevant though. Could you wonderful people of Plug
>>> remove
>>> the scales from my eyes?
>>> :-)~MIKE~(-:
>>>
>>>
>> --
>> #  http://www.LuftHans.com/        http://www.PhxLinux.org/
>> #  "Metrosexuals notwithstanding, quiche still lacks something." -- David
>> Brin
>> ---------------------------------------------------
>> PLUG-discuss mailing list - PLUG-discuss at lists.phxlinux.org
>> To subscribe, unsubscribe, or to change your mail settings:
>> http://lists.phxlinux.org/mailman/listinfo/plug-discuss
>>
>
>
> ---------------------------------------------------
> PLUG-discuss mailing list - PLUG-discuss at lists.phxlinux.org
> To subscribe, unsubscribe, or to change your mail settings:
> http://lists.phxlinux.org/mailman/listinfo/plug-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.phxlinux.org/pipermail/plug-discuss/attachments/20150307/9fdece57/attachment.html>


More information about the PLUG-discuss mailing list