Glam Prestige Journal

Bright entertainment trends with youth appeal.

I am trying to create a dev host file like below -

$hostname
$ramratan-pc
$sudo echo "127.0.0.1 ramratan-pc" >> /etc/hosts

How I can put output of hostname in echo string?

PS

I do not want to create bash script.

0

1 Answer

Simply do:

echo "127.0.0.1 $HOSTNAME" | sudo tee -a /etc/hosts
3

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy