Sponsored Content
Top Forums Shell Programming and Scripting Search and Replace in multiple files Post 302829621 by cartrider on Friday 5th of July 2013 10:05:41 AM
Old 07-05-2013
mfj.

I just tried your command, but got the following message:

sed: illegal option -- i


same message repeated - one for each file.

Also, if there were multiple occurrences of this line {{PreparerEmail
would the command replace email addresses for all occurrences?
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Multiple search and replace

Hi, I have different files and I want to automatically change the values of the defined variables. i want to get rid of editing all the files and make it a little bit faster. my problem is like this. 1. i will input all the new values. 2. substitute this values into the values inside the... (1 Reply)
Discussion started by: tungaw2004
1 Replies

2. Shell Programming and Scripting

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 : find . -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 ? (3 Replies)
Discussion started by: umen
3 Replies

3. 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

4. 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

5. 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

6. 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

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 & Replace in Multiple Files by reading a input file

I have a environment property file which contains: Input file: value1 = url1 value2 = url2 value3 = url3 and so on. I need to search all *.xml files under directory for value1 and replace it with url1. Same thing I have to do for all values mentioned in input file. I need script in unix bash... (7 Replies)
Discussion started by: Shamkamde
7 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
replcon(1)						      General Commands Manual							replcon(1)

NAME
replcon - SELinux file context replacement tool SYNOPSIS
replcon NEW_CONTEXT DIR [OPTIONS] [EXPRESSION] DESCRIPTION
replcon allows the user to find and replace file contexts. Replacements can be filtered by object class as described below. REQUIRED ARGUMENTS
NEW_CONTEXT The replacement context as expressed as a partial context, described below. DIR Initial directory to begin searching. The tool will recurse into any subdirectories, so be sure there are no circular mounts within it. EXPRESSION
The following options allow the user to specify which files to find. A file must meet all specified criteria for its context to be replaced. If no expression is provided, all files' contexts are replaced. -t TYPE, --type=TYPE Search for files with a context containing the type TYPE. -u USER, --user=USER Search for files with a context containing the user USER. -r ROLE, --role=ROLE Search for files with a context containing the role ROLE. -m RANGE, --mls-range=RANGE Search for files with a context with the MLS range of RANGE. Note that replcon ignores the SELinux translation library, if present. In addition, this flag is ignored if DIR has no MLS information. --context=CONTEXT Search for files matching this partial context. This flag overrides -t, -u, -r, and -m. -p PATH, --path=PATH Search for files which include PATH. -c CLASS, --class=CLASS Search only files of object class CLASS. OPTIONS
-v, --verbose Display context info during replacement. -h, --help Print help information and exit. -V, --version Print version information and exit. PARTIAL CONTEXT
The --context flag and NEW_CONTEXT argument specify a partial context, which is a a colon separated list of user, role, and type. If the system supports MLS, the context may have a fourth field that gives the range. With --context if a field is not specified or is the lit- eral asterisk, then the query will always match the field. With NEW_CONTEXT if a field is not specified or is the literal asterisk, then that portion of the context will not be modified. OBJECT CLASSES
Valid object class strings are block, char, dir, fifo, file, link, or sock. NOTE
The replcon utility always operates on "raw" SELinux file contexts. If the system has an installed translation library (i.e., libsetrans), those translations are ignored in favor of reading the original contexts from the filesystem. EXAMPLES
replcon ::type_t: . Replace every context's type in the current directory with type_t. The user and role portion remain unchanged. replcon -u user_u *:role_r:* . Replace every context's role with user user_u in the current directory with role_r. The user and type portion remain unchanged. replcon --context ::type_t:s0 :::s0:c0 /tmp Replace every context with type type_t and MLS range s0 in /tmp with MLS range s0:c0. AUTHOR
This manual page was written by Jeremy A. Mowery <jmowery@tresys.com>. COPYRIGHT
Copyright(C) 2003-2007 Tresys Technology, LLC BUGS
Please report bugs via an email to setools-bugs@tresys.com. SEE ALSO
findcon(1), indexcon(1) replcon(1)
All times are GMT -4. The time now is 10:54 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy