bash command spanning multiple lines with several lines of comments in-between
BashBash Problem Overview
> Possible Duplicate:
> Bash: How to Put Line Comment for a Multi-line Command
I would like to do something like this
sudo apt-get install \
#a very long description
#of the package
#that spans multiple lines
pkg1 \ #maybe I want an inline comment also
#another description that
#spans multiple lines
pkg2
Note that I'm not just interested in the apt-get
command.
Bash Solutions
Solution 1 - Bash
As far as I know Bash ignores everything after the '#' in a single command, and multilining won't change that. However you can probably achieve the same level of expression using bash arrays:
packagelist=(
package1 # Inline Comments
# Multiline Comments too
package2
# Package description goes here
# Detailed descriptions..
)
sudo apt-get install ${packagelist[@]}