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
mfontset_lookup(3m17n)						 The m17n Library					    mfontset_lookup(3m17n)

NAME
mfontset_lookup - Lookup a fontset. SYNOPSIS
MPlist * mfontset_lookup (MFontset * fontset, MSymbol script, MSymbol language, MSymbol charset) DESCRIPTION
Lookup a fontset. The mfontset_lookup() function lookups fontset and returns a plist that describes the contents of fontset corresponding to the specified script, language, and charset. If script is Mt, keys of the returned plist are script name symbols for which some fonts are specified and values are NULL. If script is a script name symbol, the returned plist is decided by language. o If language is Mt, keys of the plist are language name symbols for which some fonts are specified and values are NULL. A key may be Mt which means some fallback fonts are specified for the script. o If language is a language name symbol, the plist is a FONT-GROUP for the specified script and language. FONT-GROUP is a plist whose keys are FLT (FontLayoutTable) name symbols (Mt if no FLT is associated with the font) and values are pointers to MFont. o If language is Mnil, the plist is fallback FONT-GROUP for the script. If script is Mnil, the returned plist is decided as below. o If charset is Mt, keys of the returned plist are charset name symbols for which some fonts are specified and values are NULL. o If charset is a charset name symbol, the plist is a FONT-GROUP for the charset. o If charset is Mnil, the plist is a fallback FONT-GROUP. RETURN VALUE
It returns a plist describing the contents of a fontset. The plist should be freed by m17n_object_unref(). COPYRIGHT
Copyright (C) 2001 Information-technology Promotion Agency (IPA) Copyright (C) 2001-2011 National Institute of Advanced Industrial Science and Technology (AIST) Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License <http://www.gnu.org/licenses/fdl.html>. Version 1.6.2 12 Jan 2011 mfontset_lookup(3m17n)
All times are GMT -4. The time now is 07:14 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy