This is the end result of running a string of commands together
Top line = rescue kernel
Second = Would be hostname
The rest the result of kernel -q.
I have tried to add comments to the right of the sections in the script but on one section I get
#### sudo rescue_ver
#### xargs: #: No such file or directory
The two relevant lines, I hope.
### sed ‘s/[^0-9]*//’ /tmp/rescue_line >> /tmp/line_front-gone && \
### cat /tmp/line_front-gone | cut -f1 -d"/" | xargs > /tmp/line_back_gone \# Rescue Kernel && \
Both /tmp/line_front-gone and /tmp/line_back_gone exist in /tmp when testing.
But the error prevents completion, with out the \# comments it runs fine.
The trailing backslash must be the last character on the line for it to be interpreted as a continuation command. No comments or even whitespace are allowed after it.
which is why you get the error you do.
The answers there have some ideas for how you can work around it.
(This isn’t Fedora-specific, it would be the same with bash on any distro.)
Also, Bash has a nifty “exit immediately” mode that can be enabled at the the start of a script with set -e. If any simple[1] command that follows fails, the script will exit and none of the remaining commands will run. If you make use of that feature in your script, then you could eliminate && \ from the end of all your commands.
By “simple” commands, I mean ones that are not embedded in a chain of |, && or || operators and which are not part of any flow control statements such as if or while. There are rules for how more complex commands are handled. See the Bash man page for details. (In the case of commands that are chained together with |, &&, or ||, the rule is that only the failure of the last command will trigger an immediate exit.) ↩︎