Sponsored Content
Top Forums Shell Programming and Scripting serach and replace a specific pattern or value in a xml file Post 302224500 by kiranreddy1215 on Wednesday 13th of August 2008 10:02:39 AM
Old 08-13-2008
serach and replace a specific pattern or value in a xml file

can some one help me with a perl command

i have to search and replace a version from a xml-file
so i use in a ksh script a command like this
ssh $GLB_ACC@$GLB_HOST "/usr/contrib/bin/perl -pi -e "s/$curVersion/$new_Version/g" $Dest_dir/epi.xml"

this command worked so far, but the problem i found is when curLine is 10.0.0
where curVersion=10.0.0 and new_Version= 10.0.1

since with this pattern they are some more entries like IP address ,etc.. which is matching the pattern

inside the xml file its specified as
<value>10.0.0<\value>

how can i overcome the search and replace to only act on the above value
either by changing pattern ,etc.. any help please ??
i tried like this but no luck

ssh $GLB_ACC@$GLB_HOST "/usr/contrib/bin/perl -pi -e "s/value\>$curVersion\</value\>$new_Version\</g" $Dest_dir/epi.xml"

i want to know how can i search patter including "<" or ">"
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

serach and replace file name in the path in a remote xml file

hi every one , here is my problem !! i have to run my script from an account and update the result in a xml file located on a different account. i use existing ssh keys to do it remotely for example the tags looks like this <PropertyValueList... (1 Reply)
Discussion started by: kiranreddy1215
1 Replies

2. UNIX for Dummies Questions & Answers

Pattern Matching - serach and replace script

My requirement is to replace a a particular pattren in a script from A to B. I am not sure if this can be done through sed command or through awk . The file sv.inc is window DialogBox AddConnection tag "~ActiveApp/Add Connection - Provider Type?URL" I would wnat the file to be... (10 Replies)
Discussion started by: bsandeep_80
10 Replies

3. UNIX for Dummies Questions & Answers

Serach a pattern

Hi, I am trying to find a particular patter in multiple UNIX files (also contain system files,hidden files and normal files) i am now using CMD: egrep -ali 'pattern' * i am not getting the required result, i just need files path and finename Naveen (3 Replies)
Discussion started by: Naveen_5960
3 Replies

4. Shell Programming and Scripting

Help needed :Search and Replace a string pattern with empty in an xml file in unix

Search and Replace a string pattern with empty in an xml file in unix: My xml file would be like this : <Accounts><Name>Harish</Name><mobile>90844444444444445999 </mobile><TRIG>srcujim-1</TRIG></Accounts><Accounts><Name>Satish</Name><mobile>908999</mobile><TRIG>ettertrtt-1</TRIG></Accounts> ... (1 Reply)
Discussion started by: harish_s_ampeo
1 Replies

5. Shell Programming and Scripting

Mutli line pattern search & replace in a xml file

Hello guys, I need your help for a specific sed command that would search for a multi line pattern and if found, would replace it by another multi line pattern. For instance, here is the input: <RefNickName>abcd</RefNickName> <NickName>efgh</NickName> <Customize> ... (0 Replies)
Discussion started by: xciteddd
0 Replies

6. Shell Programming and Scripting

Replace column that matches specific pattern, with column data from another file

Can anyone please help with this? I have 2 files as given below. If 2nd column of file1 has pattern foo1@a, find the matching 1st column in file2 & replace 2nd column of file1 with file2's value. file1 abc_1 foo1@a .... abc_1 soo2@a ... def_2 soo2@a .... def_2 foo1@a ........ (7 Replies)
Discussion started by: prashali
7 Replies

7. UNIX for Dummies Questions & Answers

Serach pattern in one field and replace in another

Hi all, I have a TAB separated file like this: sample.rpt: 54 67 common/bin/my/home {{bla bla bla}} {bla bla} Replace Me 89 75 bad/rainy/day/out {{ some bla} } {some bla} Dontreplace Me ...... ...... I wish to do a regexp match on the 3rd... (2 Replies)
Discussion started by: newboy
2 Replies

8. Shell Programming and Scripting

Need help to replace a pattern on specific line in a data file

Hi, I want to replace specific pattern "-2.0000 2" by "1.0000 3" on a particular line (line #5) in a file 1.dat. I have about 50 more files similar to 1.dat in which I want to do this correction. Can you please suggest how can I make change only at this particular line of a file... (6 Replies)
Discussion started by: anuj06
6 Replies

9. Post Here to Contact Site Administrators and Moderators

Search for a pattern and replace a space at specific position with a Character in File

In file, we have millions of records each of 1000 in length. And at specific position say 800 there is a space, we need to replace it with Character X if the ID in that row starts with 123. So far i have used the below which is replacing space at that position to X but its not checking for... (3 Replies)
Discussion started by: Jagmeet Singh
3 Replies
APT-FILE(1)															       APT-FILE(1)

NAME
apt-file - APT package searching utility -- command-line interface SYNOPSIS
apt-file [ options ] [ action ] [ pattern ] apt-file -f [ options ] search [ file ... ] apt-file -D [ options ] search [ binary-packet.deb ... ] DESCRIPTION
apt-file is a command line tool for searching files in packages for the APT package management system. Some actions are required to run the search: find Alias for search. list List the contents of a package matching the pattern pattern. This action is very close to the dpkg -L command except the package does not need to be installed or fetched. purge remove all Contents-* files from the cache directory. search Search in which package a file is included. A list of all packages containing the pattern pattern is returned. apt-file will only search for filenames, not directory names. This is due to the format of the Contents files it searches. show Alias for list. update Resynchronize the package contents from their sources. The lists of the contents of packages are fetched from the location(s) speci- fied in /etc/apt/sources.list. This command attempts to fetch the Contents-<ARCH>.gz files from remote sources. For downloading these uses either the curl or wget commands as specified in apt-file.conf. OPTIONS
-a, --architecture architecture Sets architecture to architecture. This option is useful if you search a package for a different architecture from the one installed on your system. It determines how the $ARCH variable in sources.list is expanded (but it does not influence the search in any other way). -c, --cache cache-directory Sets the cache directory to cache-directory instead of its default. If executed as non-root user, the default is $HOME/.cache/apt- file with fall-back to /var/cache/apt/apt-file. The latter is also the default if apt-file is called as root. -d, --cdrom-mount cdrom-mount-point Use cdrom-mount-point instead of apt's. -D, --from-deb Use contents of the given .deb archives(s) as patterns. Useful for searching for file conflicts with other packages. Implies -F. -f, --from-file Read patterns from the given file(s), one per line. Use -f - for stdin. This is much faster than invoking apt-file many times. -F, --fixed-string Do not expand search pattern with generic characters at pattern's start and end. -i, --ignore-case Ignore case when searching for pattern. -l, --package-only Only display package name; do not display file names. -N, --non-interactive Skip schemes that are listed in the interactive line in apt-file.conf. This is useful if you want to call 'apt-file update' in cron jobs and skip all schemes that may require user input. -s, --sources-list sources.list Sets the sources.list file to a different value from its default /etc/apt/sources.list. -v, --verbose Run apt-file in verbose mode. -x, --regexp Treat pattern as a (perl) regular expression. See perlreref(1) for details. Without this option, pattern is treated as a literal string to search for. -y, --dummy Run in dummy mode (no action). -h, --help Display a short help screen. CONFIGURATION FILE
The apt-file configuration file can be found in /etc/apt/apt-file.conf. A string expansion is done on several values. See the string expansion section. destination This variable describes how cached files will be named. http | ftp | ssh | rsh | file | cdrom Defines the commands used to fetch files. STRING EXPANSION A sources.list entry is defined as: deb uri dist component1 component2 ... A uri is defined as: proto:/[/][user[:password]@]host[:port][/path] <host> replace with the hostname <port> replace with the port number <uri> replace with full uri <path> replace with full path (relative to / on the host) <dist> replace with distribution name <comp> replace with component name <cache> replace with cache directory <dest> replace with destination expanded value. <cdrom> replace with cdrom-mount-point. BUGS
The cdrom backend has not been tested. Non-release lines in sources.list are not handled by apt-file. There is only one Contents file per distribution that contains all components (i.e. main, contrib, and non-free). Threrefore, apt-file will display search results from all components, even if not all components are included in the sources.list file. When a new line has been added to the sources.list and apt-file update has not been run, apt-file does not print a warning message. Complex regular expressions that match the leading slash may not work correctly. As a workaround, try to pull the leading slash to the beginning of the regular expression. For example, use "/(usr/bin/vim|sbin/lvm)" instead of "/usr/bin/vim|/sbin/lvm". FILES
/etc/apt/sources.list Locations to fetch package contents from. /etc/apt/sources.list.d/ Directory with additional sources.list snippets /etc/apt/apt-file.conf Configuration file for apt-file. SEE ALSO
auto-apt(1), apt-cache(8), apt-cdrom(8), dpkg(8), dselect(8), sources.list(5), apt.conf(5), apt_preferences(5). The APT users guide in /usr/share/doc/apt/ AUTHOR
apt-file was written by Sebastien J. Gross <sjg@debian.org>. May 2003 APT-FILE(1)
All times are GMT -4. The time now is 03:58 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy