There are different ways you can preserve indentation in Linux bash shell. Below is a simple example of preserving indentation while writing to a file or saving to a variable in Linux bash shell.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
## Preserve indentation while writing to a file cat << EOF > file.yaml - martin: name: Martin D'vloper job: Developer skills: - python - perl - pascal EOF cat file.yaml ## Preserve indentation while storing to a variable var1=$(< file.yaml) echo "$var1" |