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
gopher://sdf-eu.org/1/users/njsg
.



Relevant Pages

  • Re: The linf project
    ... I like French quotes as well. ... doubling up issue for embedding the string quote. ... Explict concatenation to deal with doubling up seems ...
    (comp.lang.fortran)
  • Re: sed search and replace
    ... > I have a CSV file which I created by concatenation of multiple files. ... > In some of the files the fields are also delimited with double quotes. ...
    (comp.unix.shell)
  • Re: sed search and replace
    ... >> I have a CSV file which I created by concatenation of multiple files. ... >> In some of the files the fields are also delimited with double quotes. ...
    (comp.unix.shell)
  • Re: sed search and replace
    ... Quick question now:) I have a CSV file which I ... > created by concatenation of multiple files. ... > files the fields are also delimited with double quotes. ...
    (comp.unix.shell)
  • Re: [SLE] bash Script Using Filenames with Embedded Spaces
    ... If it is a literal space for the ls command, ... wonder what effect the quotes will have placed in different places ... Antonio Vivaldi-Gloria Dixit Dominus Magnificat Choir of Kings College ...
    (SuSE)