Sponsored Content
Top Forums Shell Programming and Scripting Extended replacing of nonspecific strings in text files [beware complicated !] Post 302527064 by pasc on Thursday 2nd of June 2011 08:48:38 AM
Old 06-02-2011
Extended replacing of nonspecific strings in text files [beware complicated !]

Well, to make another post at this helpful forum SmilieSmilie:

I recently tried something like this, I want to replace all those numberings/letters that are located
between <string>file://localhost/var/mobile/Applications/ and /Documents/</string>

numberings =[Number/Letter]-[Number/Letter]-[Number/Letter]-[Number/Letter]-[Number/Letter]

replace with:
  • first instance with 1234
  • scnd instance with 1234
  • thrd instance with 5678
  • fourth instance with 5678
  • fifths instance with 1010
  • sithth instance with 1010
  • seventh instance with 1111
  • eighth instance with 1111
[I marked them down in the example: ]

The text file:
[spoiler]
Code:
 <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Children</key>
  <array>
    <dict>
      <key>URIDictionary</key>
      <dict>
        <key></key>
        <string>file://localhost/var/mobile/Media/Downloads/</string>
        <key>title</key>
        <string>Downloads</string>
      </dict>
      <key>URLString</key>
      <string>file://localhost/var/mobile/Media/Downloads/</string>
      <key>WebBookmarkType</key>
      <string>WebBookmarkTypeLeaf</string>
      <key>WebBookmarkUUID</key>
      <string>FCA20256-B43E-4B7B-B496-116EAB4F0937</string>
    </dict>
    <dict>
      <key>URIDictionary</key>
      <dict>
        <key></key>
        <string>file://localhost/var/mobile/Applications/453F6009-876D-4757-8111-2201555C96C3/Documents/</string>
        <key>title</key>
        <string>iCab Downloads</string>
      </dict>
      <key>URLString</key>
      <string>file://localhost/var/mobile/Applications/453F6009-876D-4757-8111-2201555C96C3/Documents/</string>
      <key>WebBookmarkType</key>
      <string>WebBookmarkTypeLeaf</string>
      <key>WebBookmarkUUID</key>
      <string>DC9D8A8C-B0F0-4E13-8F8B-167BBF9DE0C5</string>
    </dict>
    <dict>
      <key>URIDictionary</key>
      <dict>
        <key></key>
        <string>file://localhost/var/mobile/Applications/FC972FD1-DA09-4FD5-9BDE-3B292946DA36/Documents/</string>
        <key>title</key>
        <string>iDownloads</string>
      </dict>
      <key>URLString</key>
      <string>file://localhost/var/mobile/Applications/FC972FD1-DA09-4FD5-9BDE-3B292946DA36/Documents/</string>
      <key>WebBookmarkType</key>
      <string>WebBookmarkTypeLeaf</string>
      <key>WebBookmarkUUID</key>
      <string>EDBE01E6-14BC-408A-8D67-85C4E37E4074</string>
    </dict>
    <dict>
      <key>URIDictionary</key>
      <dict>
        <key></key>
        <string>file://localhost/var/mobile/Applications/3FFE1C4B-F8B4-483E-AACB-324718DEA9E4/Documents/</string>
        <key>title</key>
        <string>wikiamo</string>
      </dict>
      <key>URLString</key>
      <string>file://localhost/var/mobile/Applications/3FFE1C4B-F8B4-483E-AACB-324718DEA9E4/Documents/</string>
      <key>WebBookmarkType</key>
      <string>WebBookmarkTypeLeaf</string>
      <key>WebBookmarkUUID</key>
      <string>734D7530-6A0D-4F8F-A05D-0AA084E4C0F4</string>
    </dict>
    <dict>
      <key>URIDictionary</key>
      <dict>
        <key></key>
        <string>file://localhost/var/mobile/Applications/3B26CD6B-6E8B-4AB6-9A33-7ED1A2818FC1/Documents/</string>
        <key>title</key>
        <string>Manga BDR</string>
      </dict>
      <key>URLString</key>
      <string>file://localhost/var/mobile/Applications/3B26CD6B-6E8B-4AB6-9A33-7ED1A2818FC1/Documents/</string>
      <key>WebBookmarkType</key>
      <string>WebBookmarkTypeLeaf</string>
      <key>WebBookmarkUUID</key>
      <string>FCB13D18-D02B-4864-B62F-B2CF3B5606CA</string>
    </dict>
      <dict>
        <key></key>
        <string>file://localhost/var/mobile/Media/Documents/</string>
        <key>title</key>
        <string>Documents</string>
      </dict>
      <key>URLString</key>
      <string>file://localhost/var/mobile/Media/Documents/</string>
      <key>WebBookmarkType</key>
      <string>WebBookmarkTypeLeaf</string>
      <key>WebBookmarkUUID</key>
      <string>DC8D8A8C-B0R0-4E13-8F8T-167BBF9DE0C5</string>
    </dict>
  </array>
  <key>WebBookmarkFileVersion</key>
  <integer>1</integer>
  <key>WebBookmarkType</key>
  <string>WebBookmarkTypeList</string>
  <key>WebBookmarkUUID</key>
  <string>iFileBookmarkRoot</string>
</dict>
</plist>

[/spoiler]

Last edited by pasc; 06-02-2011 at 11:05 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replacing lines in text files

Hi, I have 2 sets of text files. I need to take a field from a certain line in set 1 and put it in the same place in set b. The line appears once per file, in different places but is a set format and has the unique word "ANTENNA" in it and is always 81 characters long. Example from set a: ... (7 Replies)
Discussion started by: Jonny2Vests
7 Replies

2. Shell Programming and Scripting

Find information from complicated strings

Hi experts, I have the file with these lines: var1=thu_13:12:32,var2=Microsoft,var3=240ms,var4=Mozilla/4.0_(sun;_MSIR_3-4;_windows.;_NET_1.1323.53 var1=thu_13:13:32,var2=Microsoft,var3=213ms,var4=Mozilla/4.0_(sun;_MSIR_3-4;_windows.;_NET_1.1323.53... (9 Replies)
Discussion started by: lalelle
9 Replies

3. Shell Programming and Scripting

replacing strings with text from other file

Hi, Im trying to update some properties files with text from another file: file1 user=xyz file2 user= after script file2 user=xyz Im using this reading the $QUARTZURL,ETC... from quartz.properties: echo... (1 Reply)
Discussion started by: mc1392
1 Replies

4. Shell Programming and Scripting

Text strings in files.

Hi all I have two files X.txt and Y.txt. The file format of X.txt is : madras is also the fountainhead of the theosophical movement which spread worldwide . and second file Y.txt is of the format: madra|s|nsubj is|cop also|advmod the|det fountainhead|empty of|prep the|det... (3 Replies)
Discussion started by: my_Perl
3 Replies

5. Shell Programming and Scripting

Search complicated strings on file

Can someone help me? I been figuring out how I can search and extract a complicated search string from a file. The whole string is delimited by a period. And the file where I'm searching is composed of differnt string such as that. For example, I have this search string: and I have a file... (3 Replies)
Discussion started by: Orbix
3 Replies

6. Shell Programming and Scripting

Replacing variable Text between fixed strings

Hello all, This is my first post and I hope you can help me out. I searched for quite some hours now and haven't found a simple solution to my problem. It is as following: I got this file: dl.dropbox.com/u/14586156/stuff/Bookmarks.plist and want to replace the Text between... (9 Replies)
Discussion started by: pasc
9 Replies

7. Shell Programming and Scripting

Finding/replacing strings in some files based on a file

Hi, We have a file (e.g. a .csv file, but could be any other format), with 2 columns: the old value and the new value. We need to modify all the files within the current directory (including subdirectories), so find and replace the contents found in the first column within the file, with the... (9 Replies)
Discussion started by: Talkabout
9 Replies

8. Shell Programming and Scripting

Finding a text in files & replacing it with unique strings

Hallo Everyone. I have to admit I'm shell scripting illiterate . I need to find certain strings in several text files and replace each of the string by unique & corresponding text. I prepared a csv file with 3 columns: <filename>;<old_pattern>;<new_pattern> ... (5 Replies)
Discussion started by: gordom
5 Replies

9. Shell Programming and Scripting

Replacing strings in various files

i'm trying to figure out the easiest way to replace a string: pineapple pineapple-reg basketball basketball-reg football foot-reg-ball i'm storing the above in a file called wordstoreplace.txt for each line above, the word in the first column is to be replaced by the word in the second... (4 Replies)
Discussion started by: SkySmart
4 Replies

10. Shell Programming and Scripting

Extended ASCII Characters keep on getting reintroduced to text files

I am working with a log file that I am trying to clean up by removing non-English ASCII characters. I am using Bash via Cygwin on Windows. Before I start I set: export LC_ALL=C I clean it up by removing all non-English ASCII characters with the following command; grep -v $''... (4 Replies)
Discussion started by: lewk
4 Replies
All times are GMT -4. The time now is 02:45 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy