On Mon, Nov 25, 2013 at 11:45:39PM -0800, edwardu...@live.com wrote: > 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.
There are some other options of "nesting" as well. You can use backticks "`" or $(...) to run a command "inside" another. An example would be emerge `qlist -CI x11-drivers` (or the equivalent emerge $(qlist -CI x11-drivers) ) . This would run "qlist -CI x11-drivers" (lists installed packages of the category x11-drivers) and use this output for emerge (which will effectively result in reinstalling every package from the x11-drivers category). WKR Hinnerk
signature.asc
Description: Digital signature