Sponsored Content
Top Forums Shell Programming and Scripting sed replace is giving me sore thumbs Post 303040902 by MadeInGermany on Friday 8th of November 2019 12:53:19 PM
Old 11-08-2019
The fixes are ^version to require the beginning of the line, and \" for a " within " ".
Short solutions:
Code:
sed "s/^\(version=\).*/\1\"$new_version\",/"  filename.txt

Code:
sed "/^version=/ s/=.*/=\"$new_version\",/"  filename.txt

 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

using sed to replace ' with `

Dear All, I am writting a shell script program on AIX server version 5.3 in which I am doing cleaningprocess for files in which I am trying to replace ' with ` . and for this I am using following command: sed -e 's//$/g' -e 's/\\/\//g' -e 's/'/`/g' $file >>... (2 Replies)
Discussion started by: mr_dba01
2 Replies

2. UNIX for Dummies Questions & Answers

Delete files Recursively *thumbs*.jpg

Greetings, I need to delete all files that contain the word thumbs. Those files are spread all throughout sub-directories in a file directory tree. Is there a script or single line command that will find all files with the word thumbs, and simply delete the file? For example: Delete... (4 Replies)
Discussion started by: ..Chris..
4 Replies

3. Shell Programming and Scripting

Loop with sed command to replace line with sed command in it

Okay, title is kind of confusion, but basically, I have a lot of scripts on a server that I need to replace a ps command, however, the new ps command I'm trying to replace the current one with pipes to sed at one point. So now I am attempting to create another script that replaces that line. ... (1 Reply)
Discussion started by: cbo0485
1 Replies

4. UNIX for Dummies Questions & Answers

sed - how to replace ' with \'

Hello, I have problem I can't solve. My task is to replace all apostrophes in my music library eg. I'm free to I/'m free I can select ' (apostrophe), but I can't find "to" section.. '/ echo "I'm free" | sed 's/'\''/what_shell_i_put_here/g' many thanks in advance, peter (3 Replies)
Discussion started by: piogac6088
3 Replies

5. Shell Programming and Scripting

How to use sed to replace the a string in the same file using sed?

How do i replace a string using sed into the same file without creating a intermediate file? (7 Replies)
Discussion started by: gomes1333
7 Replies

6. Shell Programming and Scripting

Sed in vi - \r and \n not giving desired results

I use many different machines at work, each with different versions of o/s's and installed applications. Sed in vi is particularly inconvenient in the sense that sometimes it will accept the "\r" as a carriage return, sometimes not. Same thing with "\n". For instance, if I have a list of hosts... (7 Replies)
Discussion started by: MaindotC
7 Replies

7. Shell Programming and Scripting

sed -i option giving error no such file or directory

I created a shell with sed -i option. It is giving error - No such file or directory Ex - sed -i 's/yes/no' yes.txt sed -i 's/why/where' yes.txt sed -i 's/when/how' yes.txt Error - :No such file or directory When I run single line in my script say sed -i 's/yes/no' yes.txt... (10 Replies)
Discussion started by: yahoo
10 Replies

8. Shell Programming and Scripting

sed and awk giving error ./sample.sh: line 13: sed: command not found

Hi, I am running a script sample.sh in bash environment .In the script i am using sed and awk commands which when executed individually from terminal they are getting executed normally but when i give these sed and awk commands in the script it is giving the below errors :- ./sample.sh: line... (12 Replies)
Discussion started by: satishmallidi
12 Replies

9. UNIX for Dummies Questions & Answers

sed Replace

I have a file whose output words are always like this: aaaa bbbb cccc dddd. Trying to arrange the data so that there are 2 columns such that the 1st word become the 1st column like this: aaaa aaaa aaaa bbbb aaaa cccc aaaa dddd Trying to use awk... (8 Replies)
Discussion started by: jimmyf
8 Replies
replace(1)							  MySQL database							replace(1)

NAME
replace - A utility program that is used by msql2mysql, but that has more general applicability as well. replace changes strings in place in files or on the standard input. Uses a finite state machine to match longer strings first. Can be used to swap strings. USAGE
replace [-?svIV] from to from to ... -- [files] or replace [-?svIV] from to from to ... < fromfile > tofile SYNOPSIS
replace [-?|-I] [-s] [-v] DESCRIPTION
replace -?|-I info -s silent -v verbose EXTRA INFO
Special characters in from string: ^ Match start of line. $ Match end of line.  Match space-character, start of line or end of line. For a end  the next replace starts locking at the end space-character. A  alone in a string matches only a space-character. EXAMPLE
this command swaps a and b in the given files: shell> replace a b b a -- file1 file2 ... SEE ALSO
isamchk(1), isamlog(1), mysql(1), mysqlaccess(1), mysqladmin(1), mysqld(1), mysqld_multi(1), mysqld_safe(1), mysqldump(1), mysql_fix_privi- lege_tables(1), mysqlshow(1), mysql_zap(1), perror(1), For more information please refer to the MySQL reference manual, which may already be installed locally and which is also available online at http://www.mysql.com/doc/en/ BUGS
Please refer to http://bugs.mysql.com/ to report bugs. AUTHOR
Ver 1.0, distribution 4.0.24 Michael (Monty) Widenius (monty@mysql.com), MySQL AB (http://www.mysql.com/). This software comes with no warranty. Manual page by L. (Kill-9) Pedersen (kill-9@kill-9.dk), Mercurmedia Data Model Architect / system developer (http://www.mercur- media.com) ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +--------------------+------------------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +--------------------+------------------------------------+ |Availability | SUNWmysqlr, SUNWmysqlu, SUNWmysqlt | +--------------------+------------------------------------+ |Interface Stability | External | +--------------------+------------------------------------+ NOTES
Source for mysql is available on http://opensolaris.org. MySQL 4.0 19 December 2000 replace(1)
All times are GMT -4. The time now is 06:44 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy