On Tue, 26 Nov 2013 01:16:45 +0200
Alan McKinnon <alan.mckin...@gmail.com> wrote:

> You don't do it that way. I understand what you want to do, but your
> description makes no sense.
> 
> How you do it is by running two commands on one line, one after the other.
> 
> To copy a file "myfile.txt" to /tmp and also change it's permissions,
> use the ";" separator:
> 
> cp myfile.txt /tmp ; chmod 644 /tmp/myfile.txt
> 
> That runs the first command (cp) and then blindly runs the second one.
> 
> 
> 
> 
> Sometimes you want to run the second command only if the first one
> succeeds (there's not much point in chmod'ing a file that didn't copy
> properly. "&&" does this:
> 
> cp myfile.txt /tmp && chmod 644 /tmp/myfile.txt
> 
> "&&" is boolean logic and a very common programming trick. I won't bore
> you with details - it gets complex and we'd have to deal with brash
> crazies like why true and false is the wrong way round the the rest of
> the world, but just know it this way:
> 
> the second command (chmod) will only run if the first (cp) succeeded. If
> it failed, the chmod will not be be tried.
> 
> Note that "&&" is definitely not the same thing as just one "&" - that
> is something completely different. Bash is full of such stuff, it's all
> done deliberately to mess with your head :-)
> 
Thanks for the prompt reply and free lesson, I appreciate it:-)
Yes...this is exactly what I was looking for. 

-- 
edwardu...@live.com <edwardu...@live.com>

Reply via email to