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 9145007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:24:27+00:00 2026-06-17T10:24:27+00:00

I have the following /etc/hosts file [root@vhost41 tmp]# cat hosts 127.0.0.1 localhost localhost.localdomain localhost4

  • 0

I have the following /etc/hosts file

[root@vhost41 tmp]# cat hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
119.13.248.1 ccvcds1.ihost.com vcds1
171.221.160.11 vhost.ihost.com vhost41


[root@vhost41 tmp]# echo $(ifconfig eth0 | grep "inet addr:" | cut -d ":" -f 2 | cut -d " " -f 1)
171.221.160.11

How can I use sed or awk a single line to add “AWSHOST” to the the matching ip line. So the change would be:

[root@vhost41 tmp]# cat hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
119.13.248.1 ccvcds1.ihost.com vcds1
171.221.160.11 vhost.ihost.com vhost41 AWSHOST

I tried to pipe the outputof the above command to sed and awk and it is not working. Any help greatly appreciated

  • 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-06-17T10:24:28+00:00Added an answer on June 17, 2026 at 10:24 am
    sed -i "/$(ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | cut -d' ' -f1)[ \t]/ s/$/ AWHOST/ " hosts
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a proper /etc/hosts file with the following contents: 127.0.0.1 localhost 255.255.255.255 broadcasthost
I have a XML structure like the following: <Root> <Node Name=File System> <Node Name=C:\Windows\System32\drivers\etc\hosts>
This is what I have in my etc/hosts file: 127.0.0.1 localhost 127.0.1.1 gotqn-System-Product-Name 127.0.0.1
In the file C:\WINDOWS\system32\drivers\etc\hosts I have only the following line 192.168.0.23 computername.domain.com computername When
I have a centOS system(embedded and has very binaries) with the following /etc/hosts. $cat
After modifying my hosts file I have appended the location for testunc to 127.0.0.1.
I have the following script: cat > /tmp/script.sh <<EndOfScript #!/bin/sh ulimit -n 8192 run_app
I have the following lines in my .zshrc source /etc/profile source $HOME/.profile My .profile
Say I have the following class: class Foo { // ctor etc here public
I have the following layout for my mvc project: /Controllers /Demo /Demo/DemoArea1Controller /Demo/DemoArea2Controller etc...

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.