Sponsored Content
Top Forums Shell Programming and Scripting Need to search and replace in multiple files in directory hierarchy Post 302153123 by shamrock on Sunday 23rd of December 2007 04:14:49 PM
Old 12-23-2007
Quote:
Originally Posted by umen
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 --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 ?
Code:
find . -name "*.dsp" | xargs -i sed 's/Test.lib//g' {}

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to do search and replace on text files in directory

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

Complex Search/Replace Multiple Files Script Needed

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

Search & Replace in Multiple Files by reading a input file

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

Global search and replace across multiple files

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

String search and replace in multiple files.

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

Replace directory paths in multiple files at once

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

perl: search replace in multiple files

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

Search & Replace: Multiple Strings / Multiple Files

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

Search and Replace in multiple files

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

Search/Replace in multiple files recursively

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
Test::Module::Used(3pm) 				User Contributed Perl Documentation				   Test::Module::Used(3pm)

NAME
Test::Module::Used - Test required module is really used and vice versa bitween lib/t and META.yml SYNOPSIS
#!/usr/bin/perl -w use strict; use warnings; use Test::Module::Used; my $used = Test::Module::Used->new(); $used->ok; DESCRIPTION
Test dependency between module and META.yml. This module reads META.yml and get build_requires and requires. It compares required module is really used and used module is really required. Important changes Some behavier changed since 0.1.3_01. o perl_version set in constructor is prior to use, and read version from META.yml(not read from use statement in *.pm) o deprecated interfaces are deleted. (module_dir, test_module_dir, exclude_in_moduledir and push_exclude_in_moduledir) methods new create new instance all parameters are passed by hash-style, and optional. in ordinary use. my $used = Test::Module::Used->new(); $used->ok(); all parameters are as follows.(specified values are default, except exclude_in_testdir) my $used = Test::Module::Used->new( test_dir => ['t'], # directory(ies) which contains test scripts. lib_dir => ['lib'], # directory(ies) which contains module libs. test_lib_dir => ['t'], # directory(ies) which contains libs used ONLY in test (ex. MockObject for test) meta_file => 'META.json' or 'META.yml' or 'META.yaml', # META file (YAML or JSON which contains module requirement information) perl_version => '5.008', # expected perl version which is used for ignore core-modules in testing exclude_in_testdir => [], # ignored module(s) for test even if it is used. exclude_in_libdir => [], # ignored module(s) for your lib even if it is used. exclude_in_build_requires => [], # ignored module(s) even if it is written in build_requires of META.yml. exclude_in_requires => [], # ignored module(s) even if it is written in requires of META.yml. ); if perl_version is not passed in constructor, this modules reads meta_file and get perl version. exclude_in_testdir is automatically set by default. This module reads lib_dir and parse "pacakge" statement, then found "package" statements and myself(Test::Module::Used) is set. exclude_in_libdir is also automatically set by default. This module reads lib_dir and parse "package" statement, found "package" statement are set.(Test::Module::Used isnt included) ok() check used modules are required in META file and required modules in META files are used. my $used = Test::Module::Used->new( exclude_in_testdir => ['Test::Module::Used', 'My::Module'], ); $used->ok; First, This module reads META.yml and get build_requires and requires. Next, reads module directory (by default lib) and test directory(by default t), and compare required module is really used and used module is really required. If all these requirement information is OK, test will success. It is NOT allowed to call ok(), used_ok() and requires_ok() in same test file. used_ok() Only check used modules are required in META file. Test will success if unused requires or build_requires are defined. my $used = Test::Module::Used->new(); $used->used_ok; It is NOT allowed to call ok(), used_ok() and requires_ok() in same test file. requires_ok() Only check required modules in META file is used. Test will success if used modules are not defined in META file. my $used = Test::Module::Used->new(); $used->requires_ok; It is NOT allowed to call ok(), used_ok() and requires_ok() in same test file. push_exclude_in_libdir( @exclude_module_names ) add ignored module(s) for your module(lib) even if it is used after new()'ed. this is usable if you want to use auto set feature for exclude_in_libdir but manually specify exclude modules. For example, my $used = Test::Module::Used->new(); #automatically set exclude_in_libdir $used->push_exclude_in_libdir( qw(Some::Module::Which::You::Want::To::Exclude) );#module(s) which you want to exclude $used->ok(); #do test push_exclude_in_testdir( @exclude_module_names ) add ignored module(s) for test even if it is used after new()'ed. this is usable if you want to use auto set feature for exclude_in_testdir but manually specify exclude modules. For example, my $used = Test::Module::Used->new(); #automatically set exclude_in_testdir $used->push_exclude_in_testdir( qw(Some::Module::Which::You::Want::To::Exclude) );#module(s) which you want to exclude $used->ok(); #do test AUTHOR
Takuya Tsuchida <tsucchi@cpan.org> SEE ALSO
Test::Dependencies has almost same feature. REPOSITORY
http://github.com/tsucchi/Test-Module-Used <http://github.com/tsucchi/Test-Module-Used> COPYRIGHT AND LICENSE
Copyright (c) 2008-2011 Takuya Tsuchida This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.12.3 2011-01-28 Test::Module::Used(3pm)
All times are GMT -4. The time now is 05:23 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy