Sponsored Content
Top Forums Shell Programming and Scripting SED to replace exact match, not first occurrence. Post 302486718 by anurag.singh on Monday 10th of January 2011 06:38:28 AM
Old 01-10-2011
Depending on how exactly you want to edit:
If you want to change all line having "Chocolate:5:5" to "Chocolate:5:10"
Code:
sed 's/Chocolate:5:5/Chocolate:5:10/'

OR change all lines "Banana:33:3" to "Banana:33:5"
Code:
sed 's/Banana:33:3/Banana:33:5/'

OR change line Banna pricers to 5 (whatever be the current price)
Code:
sed 's/Banana:\(.*\):\(.*\)/Banana:\1:5/'

This User Gave Thanks to anurag.singh For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed to match only exact string only in all occurences

Dear Friends, Anybody knows how to match exact lines only in multilinear. Input file: apple orange orange apple apple orange Desired output: fruit orange apple fruit i used the command (1 Reply)
Discussion started by: vasanth.vadalur
1 Replies

2. Shell Programming and Scripting

sed print from last occurrence match until the end of file

Hi, i have file f1.txt with data like: CHECK a b CHECK c d CHECK e f JOB_START .... I want to match the last occurrence of 'CHECK' until the end of the file. I can use awk: awk '/^CHECK/ { buf = "" } { buf = buf "\n" $0 } END { print buf }' f1.txt | tail +2Is there a cleaner way of... (2 Replies)
Discussion started by: ysrini
2 Replies

3. Shell Programming and Scripting

QUESTION1: grep only exact string. QUESTION2: find and replace only exact value with sed

QUESTION1: How do you grep only an exact string. I am using Solaris10 and do not have any GNU products installed. Contents of car.txt CAR1_KEY0 CAR1_KEY1 CAR2_KEY0 CAR2_KEY1 CAR1_KEY10 CURRENT COMMAND LINE: WHERE VARIABLE CAR_NUMBER=1 AND KEY_NUMBER=1 grep... (1 Reply)
Discussion started by: thibodc
1 Replies

4. UNIX for Dummies Questions & Answers

grep and sed exact match questions

This was mistaken as homework in a different forum, but is not. These are questions that are close to what I am trying to do at work. QUESTION1: How do you grep only an exact string. I am using Solaris10 and do not have any GNU products installed. Contents of car.txt CAR1_KEY0 CAR1_KEY1... (1 Reply)
Discussion started by: thibodc
1 Replies

5. Shell Programming and Scripting

grep and sed exact match questions

This post was previously mistaken for homework, but is actually a small piece of what I working on at work. Please answer if you can. QUESTION1 How do you grep only an exact string. I am using Solaris10 and do not have any GNU products installed. Contents of car.txt CAR1_KEY0 CAR1_KEY1... (2 Replies)
Discussion started by: thibodc
2 Replies

6. UNIX for Dummies Questions & Answers

[Solved] Replace first occurrence after match

hey guys, i have been trying to work this thing out with sed with no luck :confused: i m looking for a way to replace only the first occurrence after a match for example : Cat Realized what you gotta do Dog Realized what you gotta do Sheep Realized what you gotta do Wolf Realized... (6 Replies)
Discussion started by: boaz733
6 Replies

7. Shell Programming and Scripting

Exact match using sed

I would like replace all the rows in a file if a row has an exact match to number say 21 in a tab delimited file. I want to delete the row only if it has 21 any of the rows but it should not delecte the row that has 542178 or 563421. I tried this sed '/\<21\>/d' ./inputfile > output.txt ... (7 Replies)
Discussion started by: Kanja
7 Replies

8. UNIX for Dummies Questions & Answers

sed Exact Match when Dot is present

I am trying to replace exact word from my text. I know using the angled brackets does the trick. But it is not working when there is a dot in the text. echo "Bottle BottleWater Bottle Can" | sed 's/\<Bottle\>//g' BottleWater CanBut if my data has a dot or hash in it, it replaces all the... (10 Replies)
Discussion started by: grep_me
10 Replies

9. UNIX for Dummies Questions & Answers

Code for exact match to count occurrence

Hi all, I have an input file as below. I would like to count the occurrence of pattern matching 8th field for each line. Input: field_01 field_02 field_03 field_04 field_05 field_06 field_07 field_08 TA T TA T TA TA TA... (3 Replies)
Discussion started by: huiyee1
3 Replies

10. Shell Programming and Scripting

sed print from last occurrence match until the end of last occurrence match

Hi, i have file file.txt with data like: START 03:11:30 a 03:11:40 b END START 03:13:30 eee 03:13:35 fff END jjjjjjjjjjjjjjjjjjjjj START 03:14:30 eee 03:15:30 fff END ggggggggggg iiiiiiiiiiiiiiiiiiiiiiiii I want the below output START (13 Replies)
Discussion started by: Jyotshna
13 Replies
Color::Library::Dictionary::Tango(3pm)			User Contributed Perl Documentation		    Color::Library::Dictionary::Tango(3pm)

NAME
Color::Library::Dictionary::Tango - (Tango) The Tango color palette DESCRIPTION
The Tango icon theme's goal is to make applications not seem alien on any desktop. A user running a multiplatform application should not have the impression that the look is unpolished and inconsistent with what he or she is used to. While this isn't about merging styles of all desktop systems, we do aim to not be drastically different on each platform. The Tango color palette consists of 27 RGB colors. <http://tango.freedesktop.org/Tango_Icon_Theme_Guidelines> COLORS
Aluminium 1 aluminium1 #eeeeec Aluminium 2 aluminium2 #d3d7cf Aluminium 3 aluminium3 #babdb6 Aluminium 4 aluminium4 #888a85 Aluminium 5 aluminium5 #555753 Aluminium 6 aluminium6 #2e3436 Butter 1 butter1 #fce94f Butter 2 butter2 #edd400 Butter 3 butter3 #c4a000 Chameleon 1 chameleon1 #8ae234 Chameleon 2 chameleon2 #73d216 Chameleon 3 chameleon3 #4e9a06 Chocolate 1 chocolate1 #e9b96e Chocolate 2 chocolate2 #c17d11 Chocolate 3 chocolate3 #8f5902 Orange 1 orange1 #fcaf3e Orange 2 orange2 #f57900 Orange 3 orange3 #ce5c00 Plum 1 plum1 #ad7fa8 Plum 2 plum2 #75507b Plum 3 plum3 #5c3566 Scarlet Red 1 scarletred1 #ef2929 Scarlet Red 2 scarletred2 #cc0000 Scarlet Red 3 scarletred3 #a40000 Sky Blue 1 skyblue1 #729fcf Sky Blue 2 skyblue2 #3465a4 Sky Blue 3 skyblue3 #204a87 perl v5.14.2 2011-12-07 Color::Library::Dictionary::Tango(3pm)
All times are GMT -4. The time now is 10:04 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy