Help-a small script

Source: Internet
Author: User
Help-a small script-General Linux technology-Linux programming and kernel information. The following is a detailed description. The younger brother wants to get a script to automatically import the ip host name to/etc/hosts.
My script content is as follows:
Ifconfig eth0 | grep "inet addr" | cut-d:-f 2 | cut-d ""-f 1>/etc/hosts
Hostname>/etc/hosts

There are two rows, but after importing/etc/hosts, it should be one row, but now it is two rows
How can I write and import the hosts content to make it look normal?

192.168.1.20 dxna <--- This is normal. the IP address has several spaces in the middle of the front host name.


192.168.1.20 <-- This is what my script imports. it turns out two lines are depressing.
Dxna

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.