Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding a tab in a Shell script

So I have an extremely simple shell script, where it inputs an IP address and a domain name in the hosts file of a person's computer. For "development purposes only!" it works fine, it just inputs the IP address and domain name like so

192.168.53.215dev.env.os 192.168.53.215dev.source.os

Where I want it to input it like this:

192.168.53.215 dev.env.os 192.168.53.215 dev.source.os

So basically I want it to add space between the IP address and the domain name, unfortunately I can't really figure it out. Any help would be appreciated, this is a simple script though and shouldn't be cluttered with an over complicated script. Please keep it simple and explain exactly what you're doing I would like to learn it not have it done for me thanks!

Here is the code:

do shell script "/usr/bin/printf \"\\n# Add #####'s ip for Sourcebox\\n192.168.53.215\\dev.env.os\\n192.168.53.215\\dev.source.os\\n\" >> /etc/hosts; /usr/bin/dscacheutil -flushcache" with administrator privileges
like image 267
djowinz Avatar asked Oct 28 '25 02:10

djowinz


1 Answers

Using the -e flag with echo in a bash script will allow you to output tabs.

echo -e "this\thas\ttabs"
like image 99
El Yobo Avatar answered Oct 29 '25 19:10

El Yobo



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!