![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How can I insert character to end of file? | umen | UNIX for Dummies Questions & Answers | 1 | 01-29-2008 04:47 AM |
| insert some text to a file log | bucci | Shell Programming and Scripting | 4 | 05-09-2007 04:19 AM |
| insert text into top of file | jimbob | Shell Programming and Scripting | 1 | 09-22-2006 02:46 PM |
| Insert text file at a certain line. | insania | Shell Programming and Scripting | 4 | 07-31-2006 11:46 PM |
| SED- Insert text at top of file | MBGPS | Shell Programming and Scripting | 12 | 07-03-2002 06:48 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Edit and insert character in a text file
Hello All,
Can somebody please help me how to accomplish the following : I have a text file called data.txt that has the following information : M|88494-998494 M|98jd#0094 M|88394-994049 M|GFG9980#009944 and so on... I need to replace the value of M to either "S" or "X" depending on whether there is "-" or "#" in the record. If there is a "-"m replace it with "S"..... Can I just use SED? thnaks! Joseph |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
sed
Quote:
sed -e '/\-/ s/M/S/' m.txt -ne '/\#/ s/M/X/' m.txt I have not tested it. Pls. check. Ram |
|
#3
|
||||
|
||||
|
sed -e '/\-/ s/M/S/' -e '/\#/ s/M/X/' data.txt
|
|
#4
|
|||
|
|||
|
Thank you very much! I will try it out....
Joseph |
|||
| Google The UNIX and Linux Forums |