12-23-2007
Need to search and replace in multiple files in directory hierarchy
Hello all
I need to search and replace in multiple files that are in directory hierarchy
Im using the :
f
PHP Code:
ind . -name "*.dsp" -print | xargs grep -n -o Test.lib" , I like to be able to
replace every instance of Test.lib
with empty space .
how can I write one liner that does this ?
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I was google searching and found
Perl as a command line utility tool
This almost solves my problem:
find . | xargs perl -p -i.old -e 's/oldstring/newstring/g'
I think this would create a new file for every file in my directory tree. Most of my files will not contain oldstring and I... (1 Reply)
Discussion started by: siegfried
1 Replies
2. Shell Programming and Scripting
I have a rather complicated search and replace I need to do among several dozen files and over a hundred occurrences. My site is written in PHP and throughout the old code, you will find things like
die("Operation Aborted due to.....");
For my new design skins for the site, I need to get... (2 Replies)
Discussion started by: UCCCC
2 Replies
3. Shell Programming and Scripting
Hi,
I have a folder which contains multiple config.xml files and one input file, Please see the below format.
Config Files format looks like :-
Code:
<application name="SAMPLE-ARCHIVE">
<NVPairs name="Global Variables">
<NameValuePair>
... (0 Replies)
Discussion started by: haiksuresh
0 Replies
4. Shell Programming and Scripting
Hi all
I'm in need of a command which can replace a specified string with another string - across multiple files within multiple sub-directories (I intend to run it from / )
I've used the following to get a list of the files:
find . | xargs grep <string1>
But that's as far as I've got.... (7 Replies)
Discussion started by: huskie69
7 Replies
5. Shell Programming and Scripting
Hello.
I have five config files in /etc that I want to edit in one click for testing.
I would like to make a script like this :
#!/bin/bash
#
a_file="/etc/file_1"
src_str="src_string_1"
rpl_str="rpl_string_1"
calling_sed_or_awk_or_whatelse $a_file search_for_all $src_str replace_with... (4 Replies)
Discussion started by: jcdole
4 Replies
6. Shell Programming and Scripting
I need to update about 2400 files in a directory subtree, with a new directory path inside the files
I need to change this occurence in all files: /d2/R12AB/VIS/apps/tech_st/10.1.2
with this: /u01/PROD/apps/apps_st/10.1.3
I know how to change single words using "find . -type f -print0 |... (6 Replies)
Discussion started by: wicus
6 Replies
7. Shell Programming and Scripting
When I use special characters the command to replace multiple files with a string pattern does nt work.
---------- Post updated at 12:33 PM ---------- Previous update was at 11:38 AM ----------
This works
perl -pi -e 's/100/test/g' *
This does nt work
perl -pi -e 's... (1 Reply)
Discussion started by: w020637
1 Replies
8. Shell Programming and Scripting
I have a list of files all over a file system e.g.
/home/1/foo/bar.x
/www/sites/moose/foo.txtI'm looking for strings in these files and want to replace each occurrence with a replacement string, e.g.
if I find: '#@!^\&@ in any of the files I want to replace it with: 655#@11, etc.
There... (2 Replies)
Discussion started by: spacegoose
2 Replies
9. Shell Programming and Scripting
Hello,
I have hundreds of files in which I need to change email address. Here is what I am trying to do:
1. All text files are in a directory "a"
2. In the text file, I want to replace email address for preparer. All these lines start with {{PreparerEmail and end with }}. The email... (3 Replies)
Discussion started by: cartrider
3 Replies
10. Shell Programming and Scripting
Hi there,
I am using AIX and trying to search and replace a string with another string in multiple files in different directories.
I wanted to search replace in steps so I don't change all of the instance anywhere in the server at once, minimizing impact.
STEP 1:
--------
I first searched... (5 Replies)
Discussion started by: zaino22
5 Replies
LEARN ABOUT ULTRIX
dwtopenhierarchy
DwtOpenHierarchy(3Dwt) DwtOpenHierarchy(3Dwt)
Name
DwtOpenHierarchy - Allocates a hierarchy ID and opens all the UID files in the hierarchy.
Syntax
#include <X11/DwtAppl.h>
Cardinal DwtOpenHierarchy(num_files, file_names_list, ancillary_structures_list,
hierarchy_id_return)
DRMCount num_files;
String file_names_list [];
IDBOSOpenParamPtr *ancillary_structures_list;
DRMHierarchy *hierarchy_id_return;
Arguments
num_files Specifies the number of files in the name list.
file_names_list
Specifies an array of pointers to character strings that identify the .uid files.
ancillary_structures_list
A list of operating system-dependent ancillary structures corresponding to such things as file names, clobber flag, and so forth.
This argument should be NULL for most operations. If you need to reference this structure, see the definition of IDBOSOpen-
ParamPtr in DwtAppl.h for more information.
hierarchy_id_return
Returns the search hierarchy ID. The search hierarchy ID identifies the list of .uid files that DRM will search (in order) when
performing subsequent fetch calls.
Description
The DwtOpenHierarchy function allows the user to specify the list of UID files that DRM will search in subsequent fetch operations. All
subsequent fetch operations will return the first occurrence of the named item encountered while traversing the UID hierarchy from the
first list element (UID file specification) to the last list element. This function also allocates a hierarchy ID and opens all the UID
files in the hierarchy. It initializes the optimized search lists in the hierarchy. If DwtOpenHierarchy encounters any errors during its
execution, any files that were opened are closed.
Each UID file specified in file_names_list can specify either a full directory pathname or a file name. If a UID file does not specify the
pathname it will not contain any embedded slashes (/), and it will be accessed through the UIDPATH environment variable.
The UIDPATH environment variable specifies search paths and naming conventions associated with UID files. It can contain the substitution
fields %L and %N, where the current setting of the LANG environment variable is substituted for %L and the .uid name passed to DwtOpenHier-
archy is substituted for %N. For example, the following UID path and DwtOpenHierarchy call would cause DRM to open two separate .uid
files:
UIDPATH=/uidlib/%L/%N.uid:/uidlib/%N/%L
static char *uid_files[] = {"/usr/users/me/test.uid", "test2"};
DRMHierarchy *Hierarchy_id;
DwtOpenHierarchy((DRMCount)2,uid_files, NULL, Hierarchy_id)
The first file, /usr/users/me/test.uid, would be opened as specified, as this file specification includes a pathname. The second file,
test2, would be looked for first in /uidlib/$LANG/test2.uid, and second in /uidlib/test2/$LANG.
After DwtOpenHierarchy opens the UID hierarchy, you should not delete or modify the UID files until you close the UID hierarchy by calling
DwtCloseHierarchy.
Return Values
This function returns one of these status return constants:
DRMSuccess The function executed
successfully.
DRMNotFound File not found.
DRMFailure The function failed.
See Also
DwtCloseHierarchy(3Dwt)
DwtOpenHierarchy(3Dwt)