Re: How to concatenate two (mor more) commands on one line?

peter_ha@xxxxxxxxxx (Peter Hanke) writes:

Assume I want to execute 2 commands. The second command should only processed if the first was finished successfully.

Furthermore the concatenation should take place on one line WITHOUT an "If" condition.

I though something like the following should match the conditions

"command 1" && "command 2"

In BASH, that might work, if you use *no arguments* and there are *no
trailing spaces* inside quotes.

The problem is that it treats what is between quotes as a piece, and
does not split it into smaller pieces as it usually does when there are
no quotes.

If you quote the command name and its arguments in one big string, it
will look for an executable named after that big string.

But this doesn't work. E.g. if commands contains some parameter which in turn wrapped in double quotes e.g.

"ls -l "/user/home/user/sub dir name" " && "....

gives an error

Here it does the same thing because the left side is concatenated into
one string, and it looks for something named "ls -l /user/home/user/sub
dir name ", instead of just "ls".

The problem isn't "recursive quoting", because it's not recursive, those
quotes are all handled at the same level. (Recursive would be if you had
escaped the quotes surrounding the part which was already quoted before
quoting the whole command.)

How else can I achieve command concatenation?

This I don't need to answer because it was already answered in other
post :-)

Nuno J. Silva