I want to separate a long path to multiple lines, like this:
cd foo1\ foo2\ foo3\ foo4\ bar
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
You can separate a long command into multiple lines by using backslashes, but you would need to preserve the forward-slashes and omit the leading spaces:
cd foo1\ /foo2\ /foo3\ /foo4\ /bar
The backslashes are a line-continuation marker; when bash sees them, it incorporates the next line as if it was continued at the backslash of the current line. As a result, you couldn't use leading spaces on those subsequent lines, since they'd become spaces on the current line, creating a "too many arguments" error.