0
Hoi everybody,
I am currently struggling with having to execute multiple commands in an echo. The following line is an example of the problem I am having:
echo (cd .. && pwd)
The idea is, that, when I am currently in the folder "home/Documents", the above code prints "home" - but is still in the directory "home/Documents". However, the above command fails.
The more general question is: How can I execute multiple commands in an echo and print the last result (or all results if its not possible any other way).
Thank you and kind regards.
3
Whatever you're trying to do here, I'm almost sure
– Kamil Maciorowski – 2018-08-24T10:41:27.457echo
is not the right tool. I remember your previous question, you seem to abuseecho
. Please see XY problem. What are you really trying to do with this contraption?The other thread is the actual problem - so first sudo su, then lftp and then multiple echo commands - but I think the real problem lies within the echo - that's why I asked this question in the hope, that it also answers the other one. – bublitz – 2018-08-24T10:44:57.840
1First of all, that syntax is wrong. Neither bash, nor zsh can parse that. How did you get it to run?
echo (cd .. && pwd) bash: syntax error near unexpected token cd'
– Fanatique – 2018-08-24T10:50:52.597You are too hung up on my example - I posted that to clarify the problem I have. Next time better try to solve it your own way instead of criticizing the example. Below the solution I found :-) – bublitz – 2018-08-24T10:53:33.913
2"instead of criticizing the example" -- People don't understand your code (here and in the other question). You may believe your code is self-explanatory, but it's not. Sorry, it's so wrong and hairy it triggers WTF moments. No shame in this, we all started knowing nothing. In my opinion you need to learn the tools you use and understand them. We can help you with this. Asking "what's wrong with
echo \
pwd``?" is a good start. – Kamil Maciorowski – 2018-08-24T11:13:56.847Please see this: What is wrong with
– Kamil Maciorowski – 2018-08-27T21:51:47.167echo $(stuff)
orecho \
stuff``?