Sponsored Content
Top Forums Shell Programming and Scripting awk - replace number of string length from search and replace for a serialized array Post 302332937 by otheus on Friday 10th of July 2009 12:04:55 PM
Old 07-10-2009
Er, I think you can get it done by removing the serializing code from such strings. I You can always try it:
Code:
sed -e 's#s:[0-9][0-9]*:\"sites/[a-zA-Z0-9]*/files#\"sites/SOMETHINGELSE/files#g'

If it doesn't work, Perl might be easier for the job. Something like this might work:
Code:
 perl -p -e 's#sites/[a-zA-Z0-9]*/files#sites/SOMETHINGELSE/files#g && s#s:\d+(:\\")(.*?)(\\")#"s:".length($2).$1.$2.$3#e;'

The first half looks just like your sed script. The second half works IF the first half replaced something and then it
replaces all sequences of s:<number>:\"string\" with s:<length-of-string>:\"string\".
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replace variable length numeric string

I have a customer who logged some cc and bank account numbers in their apache logs. I got the cc numbers x'd out with sed -e 's/args=\{16\}/args=XXXXXXXXXXXXXXXX/g' -e 's/cardnum=\{16\}/cardnum=XXXXXXXXXXXXXXXX/g'but that wasn't too difficult due to the value being 16 digits. The bank account... (7 Replies)
Discussion started by: mk4mzid
7 Replies

2. Shell Programming and Scripting

search and replace fixed length record file

Hi I need to be search a file of fixed length records and when I hit a particular record that match a search string, substitute a known position field In the example file below FHEAD000000000120090806143011 THEAD0000000002Y0000000012 P00000000000000001234 TTAIL0000000003... (0 Replies)
Discussion started by: nedkelly007
0 Replies

3. Shell Programming and Scripting

Search and replace particular characters in fixed length-file

Masters, I have fixed length input file like FHEAD0000000001XXXX20090901 0000009000Y1000XXX2 THEAD000000000220090901 ITM0000109393813 430143504352N22SP 000000000000RN000000010000EA P0000000000000014390020090901 TTAIL0000000003000000 FTAIL00000000040000000002 Note... (4 Replies)
Discussion started by: bittoo
4 Replies

4. UNIX for Advanced & Expert Users

Search and replace a number

a=`grep -i a.sh filename.sh|cut -d "|" -f4` b=`expr $a + 1` filename=`grep -i a.sh filename.sh` while read line do echo $line echo $filename if then echo "entered if" nawk ' BEGIN { FS="|"; OFS="|" } { sub('$a', '$b', $4) print $0}' filename.sh fi echo "exit if" done <... (1 Reply)
Discussion started by: hs.giri
1 Replies

5. Shell Programming and Scripting

awk/sed string search and replace

Need help with either sed or awk to acheive the following file1 ----- In the amazon forest The bats eat all the time... mon tue wed they would eat berries In the tropical forest The bats eat all the time... on wed bats eat nuts In the rain forest The bats eat all the time... on... (2 Replies)
Discussion started by: jville
2 Replies

6. Shell Programming and Scripting

How to use SED or AWK to search and replace an exact string

I have a file DS1 DDS DS I want to replace only "DS" to "DSmail.blah.com" in a lot of files. I tried sed 's/DS/DSmail.blah.com' but it changes all the lines . thanks in advance (2 Replies)
Discussion started by: gubbu
2 Replies

7. Shell Programming and Scripting

awk + gsub to search multiple input values & replace with located string + extra text

Hi all. I have the following command that is successfully searching for any one of the strings on all lines of a file and replacing it with the instructed value. cat inputFile | awk '{gsub(/aaa|bbb|ccc|ddd/,"1234")}1' > outputFile This does in fact replace any occurrence of aaa, bbb,... (2 Replies)
Discussion started by: dazhoop
2 Replies

8. UNIX for Advanced & Expert Users

Search and replace a array values in perl

Hi, i want to search and replace array values by using perl perl -pi -e "s/${d$i]}/${b$j]}" *.xml i am using while loop for the same. if i excute this,it shows "Substitution replacement not terminated at -e line 1.". please tell me what's wrong this line (1 Reply)
Discussion started by: arindam guha
1 Replies

9. Shell Programming and Scripting

Need to replace 32 length string to *****

Hello, I've a file file_1.txt ul.ln = 'Kb' AND (il.sum = 'ec7ccc92585adac28d9b1fb5eff0473f' or length('ec7ccc92585adac28d9b1fb5eff0473f') = 7); il.sum = '20ddc1368d588dd0b0e37c41721e05b1' OR length('20ddc1368d588dd0b0e37c41721e05b1') = 7); I need to replace the file like below - ul.ln... (4 Replies)
Discussion started by: Mannu2525
4 Replies

10. UNIX for Beginners Questions & Answers

sed inside the awk script to replace a string in the array

The requirement is i need to find an array value matching with pattern {5:{ , replace that with 5: and reassign that to same array index and print it. I write something like below and the issue is sed command is not working. If i replace " with "`" the script gives syntax error.how can i... (8 Replies)
Discussion started by: bhagya123
8 Replies
A2ENSITE(8)                                                   System Manager's Manual                                                  A2ENSITE(8)

NAME
a2ensite, a2dissite - enable or disable an apache2 site / virtual host SYNOPSIS
a2ensite [ [-q|--quiet] site] a2dissite [ [-q|--quiet] site] DESCRIPTION
This manual page documents briefly the a2ensite and a2dissite commands. a2ensite is a script that enables the specified site (which contains a <VirtualHost> block) within the apache2 configuration. It does this by creating symlinks within /etc/apache2/sites-enabled. Likewise, a2dissite disables a site by removing those symlinks. It is not an error to enable a site which is already enabled, or to disable one which is already disabled. Apache treats the very first virtual host enabled specially as every request not matching any actual directive is being redirected there. Thus it should be called 000-default in order to sort before the remaining hosts to be loaded first. OPTIONS
-q, --quiet Don't show informative messages. -m, --maintmode Enables the maintainer mode, that is the program invocation is effectuated automatically by a maintainer script. This switch should not be used by end users. -p, --purge When disabling a module, purge all traces of the module in the internal state data base. EXIT STATUS
a2ensite and a2dissite exit with status 0 if all sites are processed successfully, 1 if errors occur, 2 if an invalid option was used. EXAMPLES
a2dissite 000-default Disables the default site. FILES
/etc/apache2/sites-available Directory with files giving information on available sites. /etc/apache2/sites-enabled Directory with links to the files in sites-available for enabled sites. SEE ALSO
apache2ctl(8). AUTHOR
This manual page was written by Stefan Fritsch <sf@debian.org> (based on the a2enmod manual page by Daniel Stone <daniel@sfarc.net>) for the Debian GNU/Linux distribution. 8 June 2007 A2ENSITE(8)
All times are GMT -4. The time now is 12:53 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy