Advertisement

02.23.2003 at 09:52PM PST, ID: 20526466
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

6.0

Line match and replace, using sed or awk

Asked by JosipKulundzic in Unix Systems Programming

Tags: , , , ,

I'm making a ksh script that iterates through a file and replaces a string of words with another string of words.  I can read the file one line at a time, but don't have the code that will replace the line (made up of words and tabs) with another sequence of words.

To be more specific, the script is to change an existing emailaddress with a new one, based on the original user-emailaddress pair.  Here is a sample of my code - it obviously doesn't work but you may be able to see what I'm trying to do...

USING SED:
cat $emailfile | sed s/"$user\t$emailaddress"/"$user\t$newemailaddress"/ > $emailfile

USING AWK:
cat $emailfile | awk '{
if ("$1" == "$user") && ("$2" == "$emailaddress")
  print "$user\t$newemailaddress"
else
  print "$user\t$emailaddres"
}' > $emailfile

It seems rather simple, but I just can't seem to get it to work with more than one word.  I have tried many variations on the code and it either does nothing to the file, replaces the line with only the username, or wipes the entire file clean.  Any suggestions will be greatly appreciated...Start Free Trial
[+][-]02.23.2003 at 11:11PM PST, ID: 8006666

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.24.2003 at 08:06AM PST, ID: 8009397

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.24.2003 at 04:42PM PST, ID: 8012909

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.24.2003 at 08:47PM PST, ID: 8014106

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.25.2003 at 01:48AM PST, ID: 8015335

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.25.2003 at 02:00AM PST, ID: 8015397

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Unix Systems Programming
Tags: one, line, sed, awk, using
Sign Up Now!
Solution Provided By: CarolAnn
Participating Experts: 2
Solution Grade: C
 
 
[+][-]02.25.2003 at 02:20PM PST, ID: 8020668

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.16.2003 at 10:07PM PDT, ID: 8345980

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32