Replacing multiple words with single word using SED
Hi Team,
I have a variable which stores some values separated by commas. Requirement is to replace the comma separated values with 1 value globally using sed. Comma separated values can be of n numbers. Can you please suggest how we can achieve this. Thanks |
What have you tried and where are you stuck? Show us the effort you have put in. You're unlikely to find someone that's going to code from scratch for you
|
I think awk might work better than sed. If you have
Code:
1,2,3,4,5 Code:
$ awk -F , '{print $3}' |
The OP cannot use awk because his assignment requires he uses sed. It's homework.
jlinkels |
Welcome to LQ. You will receive very useful "soft skills" for a successful career, in addition to tech help.
I see from your profile that you returned after post#2 gave you good "real world" advice. Tell us about your Linux experience and distro/PC access, and desires/goals. In case you have zero experince, I will give you a hint: web-search: man sed Look for the 's' function/operator, and the 'g' modifier to it. At least copy&paste here, what you see as the minimal relevant key info, if not your attempt at how you would try to do your assignment. Excuse this bit of "tough love": think of this: you are on your first day at work, to simply move boxes. You ask the instructor to do it for you, so you will pass your first test. Will things turn out well? Hopefully other future students will read this!!! Edit: a helpful person hears you ask and jumps in and does it for you. You fail, the school kicks you out, it goes on your record, you starve to death. This now wll NOT happen!!! You WILL succeed!!! ... You're welcome;) We DO want you to come back and post your first actual step, no matter what real attempt it is. We enjoy guiding you, but doing ALL YOUR WORK FOR YOU would be a great dis-service to you!!! Please come back!!! Linux is fun and valuable!!! ;) |
Quote:
LQ Welcome, there are some links in there how best to use and benefit by this site. LQ Rules/Guidelines Quote:
|
All times are GMT -5. The time now is 09:02 AM. |