zsh-users
 help / color / mirror / code / Atom feed
* Globbing confusion
@ 2006-09-26  3:00 Meino Christian Cramer
  2006-09-26  4:24 ` Jean-Rene David
  0 siblings, 1 reply; 5+ messages in thread
From: Meino Christian Cramer @ 2006-09-26  3:00 UTC (permalink / raw)
  To: zsh-users

Hi,

 I am currently writing a script to remove certain files/directories
 from my /tmp for cleanup purposes.

 Besides others I want to to match all _directories_ matching the
 patterm mc-4.6.1* but dont want to remove _files_ of that pattern.

 And I dont want any errormessage, if a certain directory/file could
 not be found.

 For that purpose I tested on the commandline the following

     cd /tmp
     ls -ld ertertert(N/)    # ertertert does not exist under /tmp

 Instead of simply getting nothing back with no "not found" I got

     drwxrwxrwt 72 root root 11776 2006-09-26 04:39 .

 In a script I would kill . in that case if "ls -ld" is replaced by
 "rm -rf" ???

 What did I wrong here ?

 Keep hacking!
 mcc


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Globbing confusion
  2006-09-26  3:00 Globbing confusion Meino Christian Cramer
@ 2006-09-26  4:24 ` Jean-Rene David
  2006-09-27  2:35   ` Meino Christian Cramer
  2006-09-27  2:46   ` Meino Christian Cramer
  0 siblings, 2 replies; 5+ messages in thread
From: Jean-Rene David @ 2006-09-26  4:24 UTC (permalink / raw)
  To: zsh-users

* Meino Christian Cramer [2006.09.25 23:15]:
>  Besides others I want to to match all _directories_ matching the
>  patterm mc-4.6.1* but dont want to remove _files_ of that pattern.
> 
>  And I dont want any errormessage, if a certain directory/file could
>  not be found.

rm -rf mc-4.6.1*(/)

The "-f" option to "rm" will take care of the
warnings.

>  For that purpose I tested on the commandline the following
> 
>      cd /tmp
>      ls -ld ertertert(N/)    # ertertert does not exist under /tmp

When NULL_GLOB is set (as it is when using the "N" glob qualifier), the shell
*deletes from the command line* any pattern which generates no match.

Your command becomes:

ls -ld

which prints the entry for the current directory (".") as expected.

>  In a script I would kill . in that case if "ls -ld" is replaced by
>  "rm -rf" ???

No you wouldn't. Your command would become:

rm -rf

which does nothing.

-- 
JR


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Globbing confusion
  2006-09-26  4:24 ` Jean-Rene David
@ 2006-09-27  2:35   ` Meino Christian Cramer
  2006-09-27  2:46   ` Meino Christian Cramer
  1 sibling, 0 replies; 5+ messages in thread
From: Meino Christian Cramer @ 2006-09-27  2:35 UTC (permalink / raw)
  To: jrdavid; +Cc: zsh-users

From: Jean-Rene David <jrdavid@magma.ca>
Subject: Re: Globbing confusion
Date: Tue, 26 Sep 2006 00:24:23 -0400

> * Meino Christian Cramer [2006.09.25 23:15]:
> >  Besides others I want to to match all _directories_ matching the
> >  patterm mc-4.6.1* but dont want to remove _files_ of that pattern.
> > 
> >  And I dont want any errormessage, if a certain directory/file could
> >  not be found.
> 
> rm -rf mc-4.6.1*(/)
> 
> The "-f" option to "rm" will take care of the
> warnings.
> 
> >  For that purpose I tested on the commandline the following
> > 
> >      cd /tmp
> >      ls -ld ertertert(N/)    # ertertert does not exist under /tmp
> 
> When NULL_GLOB is set (as it is when using the "N" glob qualifier), the shell
> *deletes from the command line* any pattern which generates no match.
> 
> Your command becomes:
> 
> ls -ld
> 
> which prints the entry for the current directory (".") as expected.
> 
> >  In a script I would kill . in that case if "ls -ld" is replaced by
> >  "rm -rf" ???
> 
> No you wouldn't. Your command would become:
> 
> rm -rf
> 
> which does nothing.
> 
> -- 
> JR
> 

Hi JR,

 thanks a lot for your explanations! :)
 
 Have a nice day!
 mcc


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Globbing confusion
  2006-09-26  4:24 ` Jean-Rene David
  2006-09-27  2:35   ` Meino Christian Cramer
@ 2006-09-27  2:46   ` Meino Christian Cramer
  2006-09-27 14:22     ` Jean-Rene David
  1 sibling, 1 reply; 5+ messages in thread
From: Meino Christian Cramer @ 2006-09-27  2:46 UTC (permalink / raw)
  To: jrdavid; +Cc: zsh-users

From: Jean-Rene David <jrdavid@magma.ca>
Subject: Re: Globbing confusion
Date: Tue, 26 Sep 2006 00:24:23 -0400

> * Meino Christian Cramer [2006.09.25 23:15]:
> >  Besides others I want to to match all _directories_ matching the
> >  patterm mc-4.6.1* but dont want to remove _files_ of that pattern.
> > 
> >  And I dont want any errormessage, if a certain directory/file could
> >  not be found.
> 
> rm -rf mc-4.6.1*(/)
> 
> The "-f" option to "rm" will take care of the
> warnings.
> 
> >  For that purpose I tested on the commandline the following
> > 
> >      cd /tmp
> >      ls -ld ertertert(N/)    # ertertert does not exist under /tmp
> 
> When NULL_GLOB is set (as it is when using the "N" glob qualifier), the shell
> *deletes from the command line* any pattern which generates no match.
> 
> Your command becomes:
> 
> ls -ld
> 
> which prints the entry for the current directory (".") as expected.
> 
> >  In a script I would kill . in that case if "ls -ld" is replaced by
> >  "rm -rf" ???
> 
> No you wouldn't. Your command would become:
> 
> rm -rf
> 
> which does nothing.
> 
> -- 
> JR
> 

Hi JR,

 me again...

 I inserted 

   rm -rf /tmp/mc-4.6.1i*(/)

 into my cleanup-script for /tmp and executed it _twice_.

 First kills the directory, second run gives me:

      solfire:/home/mccramer>~/bin/cleantmp
	  /home/mccramer/bin/cleantmp:20: no matches found: /tmp/mc-4.6.1i*(/)

 Can I supress the warning also (other "rm -f"'s, which carry the (N)
 also does not print a warning when not found.)

 I tried the following:
 I mkdir a directory mc-4.6.1A and touch mc-4.6.1B then I did a 
 rm -rf /tmp/mc-4.6.1*(/N) from within a script. BOTH entries were
 removed. Only the directory should be removed.

 What I am confusing here so much ?

 Thank you very much in advance for any help !
 mcc




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Globbing confusion
  2006-09-27  2:46   ` Meino Christian Cramer
@ 2006-09-27 14:22     ` Jean-Rene David
  0 siblings, 0 replies; 5+ messages in thread
From: Jean-Rene David @ 2006-09-27 14:22 UTC (permalink / raw)
  To: zsh-users

* Meino Christian Cramer [2006.09.26 23:00]:
>  I inserted 
> 
>    rm -rf /tmp/mc-4.6.1i*(/)
> 
>  into my cleanup-script for /tmp and executed it _twice_.

Oh, my mistake. You need the (N) flag because the
warning is generated by the shell when the
globbing pattern generates no match, not by "rm".
Sorry.

>  I tried the following:
>  I mkdir a directory mc-4.6.1A and touch mc-4.6.1B then I did a 
>  rm -rf /tmp/mc-4.6.1*(/N) from within a script. BOTH entries were
>  removed. Only the directory should be removed.

Works here...

% zsh --version
zsh 4.3.2 (i686-pc-linux-gnu)

-- 
JR


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-09-27 14:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-09-26  3:00 Globbing confusion Meino Christian Cramer
2006-09-26  4:24 ` Jean-Rene David
2006-09-27  2:35   ` Meino Christian Cramer
2006-09-27  2:46   ` Meino Christian Cramer
2006-09-27 14:22     ` Jean-Rene David

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).