From: unruh on
On 2010-03-09, Phred Phungus <Phred(a)example.invalid> wrote:
> unruh wrote:
>> On 2010-03-08, Phred Phungus <Phred(a)example.invalid> wrote:
>>> Greg Russell wrote:
>>>> In news:7vjla0Fid1U1(a)mid.individual.net,
>>>> Phred Phungus <Phred(a)example.invalid> typed:
>
>> \\.c would not
>> match much of anything.
>>

IF you used it in a grep, without any other quotes, etc, it could match
something with a .c somewhere in it. If you use it as a glob it would
not do much.

If you type ls |grep \\.c
bash will first of all interpret the \\ as a single \ and hand to grep
the argument
\.c
this would tell greq that the . was to interpreted as a literal . rather
than as a general letter ( like ? is for the globbing rules of the
shell). Thus this would get anything that had a .c in it, including
apple.conf , .cshrc, ....
Not what you want.

If you tried
ls \\.c
it would not show anything interesting (unless you happened to have a
file called \.c)

Why you would write a c program to run a shell command, I have
absolutely no idea.


From: Darren Salt on
I demand that Greg Russell may or may not have written...

> In news:7vjla0Fid1U1(a)mid.individual.net,
> Phred Phungus <Phred(a)example.invalid> typed:
>> I ran this command in the place where I keep my c source files, with a
>> subdirectory named backups1. It seemed to work, but what am I to
>> think of the files with the tilde after it?
>> http://i46.tinypic.com/15wb2io.png
>> Why didn't they get moved like the other files, as they also match the
>> regex.

> "*.c~" most certainly does NOT match "*.c", as the tilde is a character
> that is not included in the regexp.

What regexp would that be? /^.*\.c$/?

--
| Darren Salt | linux at youmustbejoking | nr. Ashington, | Doon
| using Debian GNU/Linux | or ds ,demon,co,uk | Northumberland | Army
| + http://www.youmustbejoking.demon.co.uk/ & http://tartarus.org/ds/

Sorry, you'll have to type up. I can't read you.
From: unruh on
On 2010-03-09, Darren Salt <news(a)youmustbejoking.demon.cu.invalid> wrote:
> I demand that Greg Russell may or may not have written...
>
>> In news:7vjla0Fid1U1(a)mid.individual.net,
>> Phred Phungus <Phred(a)example.invalid> typed:
>>> I ran this command in the place where I keep my c source files, with a
>>> subdirectory named backups1. It seemed to work, but what am I to
>>> think of the files with the tilde after it?
>>> http://i46.tinypic.com/15wb2io.png
>>> Why didn't they get moved like the other files, as they also match the
>>> regex.
>
>> "*.c~" most certainly does NOT match "*.c", as the tilde is a character
>> that is not included in the regexp.
>
> What regexp would that be? /^.*\.c$/?

There is a difference between regexp and globbing ( as done by the shell
for commands) for files the latter is almost always what is desired, but
in something like egrep the former.

He asked about moving files with mv. That uses globbing.
mv *.c{,~} otherdir/
would move all files ending in .c or .c~
mv *.c* would move all files which contained .c in them

This is different from regexp which is used by grep

Thus you could do
mv ` /bin/ls|grep '\.c[~]*'` otherdir/
if you wanted to be incredibly clumsy.

Note that the meaning of *, of ., of \, etc are very different in
globbing from what they mean in a regexp.

>
From: The Natural Philosopher on
Phred Phungus wrote:
> Greg Russell wrote:
>> In news:7vl6hnFd86U1(a)mid.individual.net,
>> Phred Phungus <Phred(a)example.invalid> typed:
>>
>>>>> Why didn't they get moved like the other files, as they also match
>>>>> the regex.
>>>> "*.c~" most certainly does NOT match "*.c", as the tilde is a
>>>> character that is not included in the regexp.
>>> Right. I was thinking that i was grep'ing with \\.c , which, I htink,
>>> would have been different.
>>
>> That doesn't address the tilde either ... why do you repeatedly ignore
>> the
>> tilde?
>>
>>
>
> Because I've screwed up almost everything I've tried to grep in the last
> week. I need to spend a week on regex's again.
>
As with most regexp things, you could have moved the files by hand 20
times over in that time ;-)
From: Phred Phungus on
unruh wrote:

> IF you used it in a grep, without any other quotes, etc, it could match
> something with a .c somewhere in it. If you use it as a glob it would
> not do much.
>
> If you type ls |grep \\.c
> bash will first of all interpret the \\ as a single \ and hand to grep
> the argument
> \.c
> this would tell greq that the . was to interpreted as a literal . rather
> than as a general letter ( like ? is for the globbing rules of the
> shell). Thus this would get anything that had a .c in it, including
> apple.conf , .cshrc, ....
> Not what you want.
>
> If you tried
> ls \\.c
> it would not show anything interesting (unless you happened to have a
> file called \.c)

Alright, I get that.
>
> Why you would write a c program to run a shell command, I have
> absolutely no idea.
>
>

C is what I know. Unix is what I don't know. I examined return values
for differing ways to create a shell. I couldn't yet form a sensical
paragraph about, say, pipes, but I'm using my background with
programming languages to see what goes on underneath the hood of unix.

Is unruh unrest?
--
fred