Organizational Research By

Surprising Reserch Topic questions - Question:Sed - modify single character in first column without touching others

I've got a list of interfaces that I need to modify the original files . to : so I can feed them into an ifconfig script.

It looks basically like this:




Using my basic sed knowledge I can do the following:

sed -i 's/\./\:/g'

which turns all . into :.

eth0:1 192:168:0:1 255:255:255:0

Now, if I weren't modifying the original file I know I could awk '{print $1}' however I don't know how to do this when using sed -i.

I should mention that there are also certain lines that are not subinterfaces such as:


Dropping the g in sed (which I'm sure it's the right direction) unfortunately modifies the first octet for these lines to:

eth1 10:10.10.1...

asked Sep 13, 2013 in LINUX by anonymous
edited Sep 12, 2013
0 votes

Related Hot Questions

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.