Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to put a new line/carriage return in file created by a bash script

Tags:

linux

bash

In my bash script I have:

echo -e '#!/bin/sh /n GIT_WORK_TREE=/home/realopti/domains/$name git checkout -f' >> ~/domains/$name.git/hooks/post-receive

This generates:

#!/bin/sh /n GIT_WORK_TREE=/home/realopti/domains/john git checkout -f

in my post-receive file.

I'd like the file to look like:

#!/bin/sh
GIT_WORK_TREE=/home/realopti/domains/john git checkout -f

How can I make this happen.

Thank you,

Bill

like image 599
user1592380 Avatar asked Jan 25 '26 22:01

user1592380


1 Answers

That should be \n, not /n. You may also want to remove the space after it, but it doesn't matter.

like image 104
Explosion Pills Avatar answered Jan 27 '26 14:01

Explosion Pills



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!