0

Consider the below commands typed into the terminal:

$ ls
my-file.js prefix.yml

$ cat prefix.yml apiVersion: v1 kind: ConfigMap metadata: name: file1-cm namespace: default data: my-file.js: |

$ #kindly note the line feeds in the above output $ cat my-file.js let a = require('a'); let b = require('b');

module.exports = function(app, cb) { console.log(a + b); }

$ #kindly note the line feeds and indentation $ cat prefix.yml > file1-cm.yaml; cat my-file.js | while read LINE; do echo " ${LINE}" >> file1-cm.yaml; done; echo done; done $ cat file1-cm.yaml apiVersion: v1 kind: ConfigMap metadata: name: file1-cm namespace: default data: my-file.js: | let a = require('a'); let b = require('b');

module.exports = function(app, cb) { console.log(a + b); cb(); }

I was expecting a relative indentation in file1-cm.yaml file to be equivalent to the indentation my-file.js. Am I missing something in the apis of echo or read? How come cat my-file.js preserve the indendations whereas echo does not?

deostroll
  • 307

0 Answers0