On Thursday 23 August 2001 21:18, Carroll Grigsby wrote:
> Jamie:
> If you're a migrant from Windows, you can think of a bash script as sort
> of a batch file on heavy steroids. It's usually covered in those $40
> books (Mastering..., ...Unleased, Using...); in fact there are a number
> of texts devoted to this subject -- O'Reilly is an excellent source. You
> could start with the bash programming How-To; it should be on your
> desktop under Documentation.
> You've now exhausted my expertise on the subject.
> Regards,
> Carroll
>
> "Adams, Jamie" wrote:
> > lol, not a stupid question..
> >
> > I havnt a clue what all those ' 's and $;s mean, can anyone explain this
> > script step by step?
> >                    -- Jamie
> >
> > >----------
> > >From:  Dean Morrell[SMTP:[EMAIL PROTECTED]]
> > >Reply To:      [EMAIL PROTECTED]
> > >Sent:  23 August 2001 14:22
> > >To:    [EMAIL PROTECTED]
> > >Subject:       Re: [newbie] File Renaming "Perks:  Did someone say 'bash
> > > script'?"
> > >
> > ><<File: message.txt>>
> > >This is a newbie list right? [okay, good]  I don't want to be too
> > > embarassed to ask a stuped question.  Would someone be willing to
> > > explain what this does?  I
> > >mean each character has significance, right?  So what is it?  This
> > > reminds me of the random characters thrown up on my screen after
> > > disconnecting from the old
> > >BBS.
> > >
> > >At 08:34 PM 8/22/2001 -0700, you wrote:
> > >> > for i in `ls /dirname | grep -e".+ .+"`; do mv $i `echo $i |
> > >>
> > >>  gawk '{ gsub(_, ,$0) }'` ; done
> > >
> > >Dean


OK

for i in `ls /dirname`;

the phrase in backquotes will become the output of the program called--a list of files

the for statement is a for statement as in so many program languages. i is just a 
variable that will
be assigned each of the filenames in succession.  /dirname is the hypothetical name of 
the directory
where the files exist.  (You fill in your own directory name there).  The | (pipe) 
symbol of the original
proposed script said send all the output of the ls command to the program grep.  We 
can leave that out
without losing much more than a little efficiency, since grep would take only files 
that matched the 
pattern .+ .+ (at least one character followed by an embedded blank followed by 
another character)

do mv $i `echo $i | gawk '{ gsub(_, ,$0) }'` ; done

the do is simply the sub-block where everything will happen and the instruction is mv 
(move) which
renames files the $i means (evaluate the variable i here) so it is each filename in 
succession, and again we
want to call output of a program(s) echo just sends the value of i through a pipe to 
gawk, and 
the gawk command is gsub(_, ,$0) which says globally substitute _ for ' ' in the whole 
line that is passed
to you.  Then we have some syntax to say "Thus endeth the loop begun with for".


Civileme



Want to buy your Pack or Services from MandrakeSoft? 
Go to http://wwww.mandrakestore.com

Reply via email to