Rixwaan Rixwaan - 9 months ago 83
Linux Question

How do you indent when creating a multi line file from terminal?

So I need a command to make the output look like this:

[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = ssh://[email protected]/user/address.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master


I have tried the following,

printf "[core]\n repositoryformatversion = 0\n filemode = true\n bare = false\n logallrefupdates = true\n logallrefupdates = true\n[remote "origin"]\n url = ssh://[email protected]/user/address.git\n fetch = +refs/heads/*:refs/remotes/origin/*\n[branch "master"]\n remote = origin\n merge = refs/heads/master" > config


But it creates a file with these contents

[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
logallrefupdates = true
[remote origin]
url = ssh://[email protected]/user/address.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch master]
remote = origin
merge = refs/heads/master


How can I make it wehre it outputs this in the format first stated?

Answer Source

After "\n" you could use "\t" to create tabs.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download