How do you wrap a long command to the next line within a bash script file?
As a simple example, I want to run the command pushd . && cd /foo/bar && ls && popd
From the console I can do this:
pushd . \
&& cd /foo/bar \
&& ls \
&& popd
And that wraps the line. But the same code in a script file produces an error.
How do you wrap these lines to be nicely formatted?
Best Answer
Works fine here. Make sure that the backslash is the very last character on the line, and that the file uses *nix line endings.