Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1036507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:43:00+00:00 2026-05-16T14:43:00+00:00

from my ksh script . echo $IP1 $ALIAS1 >> /etc/hosts echo $IP2 $ALAIS2 >>

  • 0

from my ksh script

.

echo $IP1  $ALIAS1 >> /etc/hosts
echo $IP2  $ALAIS2 >> /etc/hosts
echo $IP3  $ALIAS3 >> /etc/hosts

I get the hosts file as the following

10.10.10.10 node1_star
10.10.10.100    node_from_some_where
10.10.1.1              Node_HP_MACHINE

what the simple way to create the following hosts file view
in order to get constant spaces between the IP to the aliases name
as the follwoing:

(it could be by printf or by echo manipulation)

10.10.10.10        node1_star
10.10.10.100       node_from_some_where
10.10.1.1          Node_HP_MACHINE
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T14:43:01+00:00Added an answer on May 16, 2026 at 2:43 pm

    printf is a powerful function that can do exactely what you want.

    printf "%-20s %s\n" "$IP1" "$ALIAS1" >> /etc/hosts
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following Ksh script gives me No such file or directory error message on
This script is to connect to different servers and copy a file from a
I have example of the follwoing lines from print command (from ksh script) first_name=raimondelita
I read a string from a file with shell script variables, and want to
I have a script (KSH script to be precise) that downloads 3 files from
the following script testssh.ksh proves that ssh have some problems when we try to
the following test syntax is part of ksh script [[ $PARAM = TRUE ]]
I need to run Java from KSH script after getting a list of files
I have written a KornShell (ksh) script that sets an array the following way:
My program involves a number of JAVA threads calling a KornShell (ksh) script file

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.