[SOLVED] Search for a character in specific word in file and replace it in the word
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
Search for a character in specific word in file and replace it in the word
Hi all ,
I have a requirement where I have a file. Contents of the file are :
The variable names can not have characters like - , : so
in this file I have to find words starting with IC and replace characters like - ,:
I want to change only the variable name , not the whole line.
I have used SED command
sed -i '/^IC/s/[^0-9 a-z A-Z _]*//g' file
when I am using this command , it is replacing the whole line
output becomes :
Distribution: Linux From Scratch, Slackware64, Partedmagic
syg00 I've given you the answer, you need to read the sed manual and do a bit of research extra characters to be deleted are easy to add if you do a bit of the work yourself, I'm not doing it all for you, this is moderately easy stuff, if you are going to learn Linux sooner or later you will have to learn regex/sed/awk, last hint use '' character sets.
I feel your a little heavy handed on the comments there Keith. Your solution provided did not mention that it was a part solution to be added to and syg00 is not the OP and as a veteran user is
quite familiar with sed. I would reiterate what has been said that your solution will not work so well for the full colon: