Questions tagged [search-and-replace]

25 questions
4
votes
3 answers

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 can I use the found parameter twice in the execute…
rubo77
  • 2,282
  • 3
  • 32
  • 63
3
votes
6 answers

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 -iname "*.new" | sed 's/.new//' | sh using grep and sed: grep…
Ali Mezgani
  • 3,810
  • 2
  • 23
  • 36
3
votes
2 answers

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 levels in) search and replace all instances of "*" in…
neezer
  • 790
  • 3
  • 10
  • 28
3
votes
1 answer

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 and export manually. What's the best approach for…
benc
  • 663
  • 1
  • 5
  • 13
2
votes
1 answer

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 variables according to variables, that i have in some…
Piduna
  • 501
  • 3
  • 10
  • 23
2
votes
1 answer

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.
M.Rezaei
  • 405
  • 4
  • 9
  • 19
2
votes
0 answers

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 disconnecting. This is a particular issue for me because I…
Cor
  • 51
  • 3
2
votes
3 answers

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 would like to create a list of search/replace…
Mike Schall
  • 241
  • 2
  • 5
1
vote
2 answers

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.
1
vote
1 answer

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" : { "Propertie1" : "xxxx", "Propertie2: "replaceme" …
Bastien974
  • 1,824
  • 12
  • 43
  • 61
1
vote
1 answer

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 consistent and doesn't change from table to table, so…
tylerl
  • 14,885
  • 7
  • 49
  • 71
1
vote
2 answers

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/assets/sym/$1 [L,NS] and add a line above it, or…
Jason
  • 361
  • 6
  • 19
1
vote
2 answers

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 available? thanks in advance,
harald
  • 393
  • 1
  • 5
  • 17
1
vote
5 answers

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)?
mjn
  • 933
  • 2
  • 12
  • 26
0
votes
1 answer

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 life. Here is a sample URL's that we would like…
1
2