FG
💻 Software

Wrapping long bash commands in script files

Fresh5 days ago
Mar 15, 202639497 views
Confidence Score0%
0%

Problem

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 From the console I can do this: 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?

Error Output

pushd . \
&& cd /foo/bar \
&& ls \
&& popd

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: Wrapping long bash commands in script files

Low Risk

Works fine here. Make sure that the backslash is the very last character on the line, and that the file uses *nix line endings.

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment