Questions tagged [search-and-replace]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
0 answers
22 views

sed behaviour depending on the file I apply it to

I have one file called test1.xml withe the following content: Hello how are you doing? And am trying to apply the following sed search and replace: sed -i 's/Hello //g' test1.xml And the file ...
0 votes
1 answer
93 views

Regular Expression in EMEditor

I am trying to make a simple find > replace regular expression. This does work fine in https://regexr.com/ to find this comment below. However the editor I use is EMEditor that i try to make a find ...
  • 1
-1 votes
1 answer
163 views

sed linux replace complex link

I am having this challenge to pass a link from a variable: InstallLocation=/opt/software/software.properties ReplaceeVar=http://localhost:1234/ab/cd/{company}/{employee}/ sed -i "s/...
0 votes
1 answer
72 views

Find and Replace using Regular Expression

I try to find a way to find and replace using EMEditor and a Regular Expression. I try to applu this for the item below: <?php /*f04b8*/ @include "\057mn\164/r\141id\057ho\155e/\164ap\151om\...
  • 41
2 votes
1 answer
10k views

How to use Ansible modules replace or inline instead shell command with SED

i have file with string: MYAPP.db.username.DEV=MYUSERNAME Where: MYAPP mean name of applications DEV means environment MYUSERNAME means name of user for connection to db I need to replace these ...
  • 511
0 votes
1 answer
780 views

SED not working with complicated string

I have a file that starts like this: [global] pid = /var/run/php-fpm/php-fpm.pid error_log = /var/log/php5-fpm.log and want to replace error_log = /var/log/php5-fpm.log with error_log = /var/...
0 votes
1 answer
616 views

Find and replace text (multichars) in .js files on Linux

I have many .js files named the same (got.js) where i just need to find and replace some text on them. The text to find is: \x72\x6Fx75\x6E And is to be replaced with: \x72\x6F\x75\x6E (just a \ in ...
  • 15
2 votes
0 answers
381 views

How to modify the message string being logged by syslog?

I have a few linux systems with the keyboard and console shared via a KVM switch. When I switch between them, I get a lot of unwanted syslog messages regarding the keyboard connecting and ...
  • 51
0 votes
1 answer
73 views

find and replace text from urls in csv data feed Debian 7 [closed]

My server OS is Debian 7. I want to add id say 'xyz' to the below URLs example.com/abc.html?id=White example.com/abc.html?id=Black Then URLs should look like example.com/abc.html?id=White&...
  • 67
1 vote
1 answer
667 views

How to substitute a string from an awk result?

I have a JSON file which contain multiple occurrence of replaceme. I only want to substitute an occurrence based on a specific string found a few line above. E.g., [...] "title" : { "...
  • 1,824
0 votes
3 answers
3k views

Change URL in Source with reverse proxy?

sometimes we make copies of live sites on another server to test new features. A lot of CMS systems hardcode the URL in the database, so it is not possible to just use another URL. On our local ...
  • 381
4 votes
3 answers
5k views

How do i use the {} operator in find execution inside exec

I tried this bash command: find /var/www/ -path '*wp-admin/index.php' -exec mv {} $(dirname {})/index_disabled But the second {} is not executed. It results in just ./index_disabled instead. How ...
  • 2,292
1 vote
1 answer
404 views

String search and replace across an entire database

After an exploit on an ASP.NET site, the client was left with a specific string of malware code sprayed across the entire database, multiple columns of multiple tables. The prepended string is ...
  • 14.9k
-1 votes
3 answers
14k views

sed replace text - escape characters

I have a mysqldump file in which I want to replace the following text <a href="/tag/ with <a href="http://www.mydomain.com/tag/ but can't find a way to correctly escape all special characters. ...
1 vote
2 answers
2k views

Search and Replace in .htaccess files in linux

I need to add this line to every .htaccess file that is located in a /home/*/site/assets/.htaccess where * can be any amount of directories deep I need to fine this text RewriteRule ^(.*)$ /site/...
  • 361
3 votes
1 answer
2k views

search and replace ldap attribute

I have a reasonably large set of data in an LDAP server. Some of the attributes appear in many places, and I would like to replace them. The data is not enormous, but it is enough to rule out editing ...
  • 663
1 vote
2 answers
992 views

lighttpd: modifying / adding content to response?

for nginx there's a very nice module available to filter a response and search/replace content in it: http://wiki.nginx.org/HttpSubModule i wonder, if there's a similar possibility for lighttpd ...
  • 393
-2 votes
1 answer
2k views

Mass search / replace string from ssh?

I am in the process of selling a network of 60 sites, they all have adsense with the same publisher id (google_ad_client="pub-xxxxxxxxxxxxxxxx") in all the files in the /home/ folder. How can I do a ...
1 vote
5 answers
2k views

Utility to search and replace text in files including subdirectories in Windows

For Linux, sed and find are an easy option to search and replace in many files including subdirectories. Is there a way to do the same in Windows (with or without PowerShell)?
  • 933
2 votes
1 answer
6k views

How to replace text string in any type file(for example binary and ...) and multiple files in linux?

I want to replace text string in any type file(for example perl,cgi,text,binary,js and ...) in multiple folder in linux. How do i do? Tanks.
  • 405
0 votes
1 answer
438 views

Mod_Rewrite Modify Query String Help

I need some assitance with a mod_rewrite rule. I am setting up a SEO Friendly director of names and have run into some problems I know there is an easy answer for but I cant get it to work to save my ...
3 votes
6 answers
11k views

How to replace a text string in multiple files in Linux

There are a variety of ways to replace one string of text with another across many files. Here are a few ways: using sed and find: sed 's/oldstring/newstring/' "$1" > "$1".new && find -...
3 votes
2 answers
2k views

Replace Wildcard Character in Filenames

I can't get this to work: I have hundreds of files that our database developer has foolishly put asterisks in, so that we have files named like this: *1*_Floorplan.jpg I need to recursively (two ...
  • 790
1 vote
2 answers
1k views

How can I replace all instances of a specified string in a text file with another string?

I have a file a.txt. I would like to replace all instances of "1.6" with "1.5" in that file, overwriting the original file.
2 votes
3 answers
1k views

Tool for multiple pattern search and replace

I am looking for an easy to use tool that will allow me to have batch of search/replace pairs. Rolling out to different environments requires us to search/replace server names in database scripts. I ...