Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Search in one type of files and replace Post 302935484 by RavinderSingh13 on Tuesday 17th of February 2015 04:38:06 AM
Old 02-17-2015
Hello ramkumar,

Following may help you in same.
Code:
find -maxdepth 1 -type f -exec grep -l "pepsi" {} \;

If happy with above comman'd result then you can use following.
Code:
find -maxdepth 1 -type f -exec sed -i "/pepsi/s/pepsi/COLA/g" '{}' \; 2>/dev/null


Thanks,
R. Singh

Last edited by RavinderSingh13; 02-17-2015 at 05:44 AM.. Reason: Added one after maxdepth
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

fast search and replace in all files

Hi I need to find one string in all files and replace tht string with blank space and need to redirect all the files into the same directory again. now i am using find ./ -name "*.dmp" | xargs perl -pi -e 's/\\N//g' | sed 's/.$//g' but now its not redirrecting properly . its taking... (21 Replies)
Discussion started by: dbsurf
21 Replies

2. Shell Programming and Scripting

Search and Replace between two files

Hi all- I've got 2 files: One is the final results and one is a result set from a query. In the final results files I have placeholder strings in there that need to be replaced by the corresponding strings from the query file. So File#1 (FINAL RESULTS) LINEID CLIENT ID REP ... (1 Reply)
Discussion started by: Cailet
1 Replies

3. Shell Programming and Scripting

search and replace in many files

I have a directory full of files. Most of the code in the files is the same accept for a few parameter values. I want to remove hard coded values and replace it with a parameter that I can pass. This is oracle pl/sql anonymous blocks. so the code is similiar to this function myfunc (p_myvar ... (1 Reply)
Discussion started by: guessingo
1 Replies

4. Shell Programming and Scripting

Search and replace text in many files

Hello, I am very new to Linux and am trying to find a way for following problem. I have a number of files in a folder as Export000.dat, Export001.dat ..and so on. Each file has a string field 'Absolute velocity'. I want it to be replaced by 'Pixel shift' in all the files. I tried something like... (4 Replies)
Discussion started by: chirag.joshi
4 Replies

5. Shell Programming and Scripting

Search and replace string in files

I'm trying to remove the following string from several files. <img heigth="1" width="1" border="0" src="http://myteenmovies.net/t.php?id=5540372">I'm using the following script #!/bin/bash # This script will search and replace all regular files for a string # supplied by the user and... (1 Reply)
Discussion started by: d13g0sv
1 Replies

6. UNIX for Dummies Questions & Answers

Search and replace across files

Hi All, HP-UX oradev3 B.11.11 U 9000/800 3251073457 I have following files all contains text like "919642990137@". I need to search this text across all files and replace it with something like "919717298765@". I was wondering, how to accomplish this task? cpmprod_status.sh... (8 Replies)
Discussion started by: alok.behria
8 Replies

7. Programming

Search and replace in two different files

Hi there, i got the following problem. i need a bash script to correct e-mail addresses in an csv. i got a huge csv like this A B C D heiner.holber.somewhere.ch heiner holber heiner.holber@somewhere.ch So A is the wrong... (8 Replies)
Discussion started by: molker
8 Replies

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

9. Shell Programming and Scripting

Search replace with awk using 2 files

I have a bit of a complex problem that I would like to solve with awk. It is essentially a 2-part problem. I have a large directory of files with the same format, each with 266 lines. The first 206 lines of each file are filled with attribute information. Then the following 60 lines consist... (4 Replies)
Discussion started by: owwow14
4 Replies

10. Shell Programming and Scripting

Search replace hostname in htm files

Need assistance in changing the hostname I have multiple html files in a directory , its src is pointing to houston.sp.com and it needs to change to alaska.sp.com . Below is the example Trying to use perl to change it . Need suggestiong <img border="0"... (3 Replies)
Discussion started by: ajayram_arya
3 Replies
AUSEARCH_ADD_INTERPRETED_ITEM(3)				  Linux Audit API				  AUSEARCH_ADD_INTERPRETED_ITEM(3)

NAME
ausearch_add_interpreted_item - build up search rule SYNOPSIS
#include <auparse.h> int ausearch_add_interpreted_item(auparse_state_t *au, const char *field, const char *op, const char *value, ausearch_rule_t how); DESCRIPTION
ausearch_add_interpreted_item adds one search condition to the current audit search expression. The search conditions can then be used to scan logs, files, or buffers for something of interest. The field value is the field name that the value will be checked for. The op vari- able describes what kind of check is to be done. Legal op values are: exists just check that a field name exists = locate the field name and check that the value associated with it is equal to the value given in this rule. != locate the field name and check that the value associated with it is NOT equal to the value given in this rule. The value parameter is compared to the interpreted field value (the value that would be returned by auparse_interpret_field(3)). The how value determines how this search condition will affect the existing search expression if one is already defined. The possible val- ues are: AUSEARCH_RULE_CLEAR Clear the current search expression, if any, and use only this search condition. AUSEARCH_RULE_OR If a search expression E is already configured, replace it by (E || this_search_condition). AUSEARCH_RULE_AND If a search expression E is already configured, replace it by (E && this_search_condition). RETURN VALUE
Returns -1 if an error occurs; otherwise, 0 for success. SEE ALSO
ausearch_add_expression(3), ausearch_add_item(3), ausearch_add_timestamp_item(3), ausearch_add_regex(3), ausearch_set_stop(3), ause- arch_clear(3), ausearch_next_event(3), ausearch-expression(5). AUTHOR
Steve Grubb Red Hat Nov 2007 AUSEARCH_ADD_INTERPRETED_ITEM(3)
All times are GMT -4. The time now is 11:32 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy