Sponsored Content
Operating Systems Linux Linux command to find and replace occurance of more than two equal sign with "==" from XML file. Post 302661083 by bakunin on Sunday 24th of June 2012 05:44:54 PM
Old 06-24-2012
Quote:
Originally Posted by RedRocks!!
Thank you for your suggestion. I have used, Below command, where it gives output in same file.
You seem to have misunderstood what i explained. "perl -i" does the same as "sed -i": it creates a temporary second file where it stores the changes and moves this over the original file as the last step.

You gain nothing by using perl (save for a considerably slower speed of execution, because native UNIX commands are way faster).

The point is simple: to edit a file you need to be able to store 2 versions of it.*) There is no way around that. The "-i" options of various tools just blur that fact by hiding this temporary file, but it is still necessary.

If you fear a long execution time for moving the file: don't. It is in fact just a change in the files i-node (which is a few bytes) as long as the temporary file and the original file are on the same filesystem. To execute

Code:
mv /path/to/fileA /path/to/fileB

takes the same time, regardless of the size of this file (as long as they both are on the same filesystem). So set your "TMP" or "TMPDIR" variable accordingly and have enough room on your disk - some 100GB should not really be a problem these times of multi-TB SAN storage fabrics.

I hope this helps.

bakunin

________________

*) actually this is not completely true, because there is a trick:

Code:
(cat /path/to/file) | sed '<somecommand>' > /path/to/file

This will work for files which are small enough to fit into memory. The downside is, that if anything goes wrong (power loss, reboot, process aborted, ...) your data will be irrevocably destroyed. You sure do not want to use this hack on critical data just to save a few GB of (temporary) diskspace.

Last edited by bakunin; 06-24-2012 at 06:51 PM..
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

"find command" to find the files in the current directories but not in the "subdir"

Dear friends, please tell me how to find the files which are existing in the current directory, but it sholud not search in the sub directories.. it is like this, current directory contains file1, file2, file3, dir1, dir2 and dir1 conatins file4, file5 and dir2 contains file6,... (9 Replies)
Discussion started by: swamymns
9 Replies

2. Shell Programming and Scripting

Interesting question - Search and replace the word after sign "="

Hi Guys, Req your help in searching and replacing the word that comes after equals(=) symbol I would like to replace the sting in bold with a string in variable. d=ABCDF8C44C22 # grep -i NIM_MASTERID ${_NIMINFO} export NIM_MASTERID=00CDF8C44C00 I'm looking to replace any word that... (4 Replies)
Discussion started by: ajilesh
4 Replies

3. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

4. UNIX for Dummies Questions & Answers

replace "," with "." only in specific columns of a file?

Hi all, I have this text file containing 9 columns separated by space. The 8th columns contains the numbers. C1 C2 C3 C4 C5 C6 C7 C8 C9 er rt yt gh iu nk il 0.07 xs yt lr ty bg iu zk nh 0,0005 lt ...etc. I want to replace the comma with full stop only in 8th coloumn. the output... (8 Replies)
Discussion started by: Unilearn
8 Replies

5. Shell Programming and Scripting

Problem with "find" and "grep" command

I want to list all files/lines which except those which contain the pattern ' /proc/' OR ' /sys/' (mind the leading blank). In a first approach I coded: find / -exec ls -ld {} | grep -v ' /proc/| /sys/' \; > /tmp/list.txt But this doesn't work. I got an error (under Ubuntu): grep:... (5 Replies)
Discussion started by: pstein
5 Replies

6. Ubuntu

How to change "more" to "more or equal" in this line?

Hi, Below line selects only dates comes after than today. I need to change below line as "more or equal": awk -F\## -v d=$(date +%Y%m%d) '{if($NF>d)print}' /usr/batch/pill.txt > /usr/batch/pill_in_use.txt When we change the code, it will print today's date and following dates only. ... (2 Replies)
Discussion started by: baris35
2 Replies

7. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

8. Shell Programming and Scripting

Delete all log files older than 10 day and whose first string of the first line is "MSH" or "<?xml"

Dear Ladies & Gents, I have a requirement to delete all the log files in /var/log/test directory that are older than 10 days and their first line begin with "MSH" or "<?xml" or "FHS". I've put together the following BASH script, but it's erroring out: for filename in $(find /var/log/test... (2 Replies)
Discussion started by: Hiroshi
2 Replies

9. UNIX for Beginners Questions & Answers

How do I redirect output from "find", either to a file or another command?

I'm trying to find out what happened to the rogue game that apt-get told me it installed, so I thought I would find the file. I went to the root and entered: find -name "rog*.*" I get a large number of lines saying my access is denied in various directories. I figure I'll practice my Unix... (14 Replies)
Discussion started by: arghvark
14 Replies
XML-RESOLVER(1) 						   User Commands						   XML-RESOLVER(1)

NAME
xml-resolver - Resolve XML entities and URIs SYNOPSIS
xml-resolver [options] keyword DESCRIPTION
xml-resolver is a simple command line XML entity and URI resolver. It takes a number of parameters and passes them through the actual resolver class, and prints out the result. The keyword argument identifies the type of resolution to perform, it must be one of "doctype", "document", "entity", "notation", "public", "system", or "uri". OPTIONS
-c catalogfile Load a particular catalog file. May be specified multiple times. -n name Set the name. -p publicid Set the public identifier. -s systemid Set the system identifier. -a Make the system URI absolute before resolution. -u uri Set the URI. -d debuglevel Set the debug level (an integer). The default is 0. FILES
/etc/java/resolver/CatalogManager.properties The central catalog manager configuration file used by xml-resolver. SEE ALSO
xml-xread(1), xml-xparse(1), java(1), the OASIS entity resolution technical committee home page at <http://www.oasis-open.org/commit- tees/entity/>. AUTHOR
Norman Walsh <Norman.Walsh@Sun.COM> 1.1 July 2004 XML-RESOLVER(1)
All times are GMT -4. The time now is 08:40 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy