Sponsored Content
Top Forums Shell Programming and Scripting sed to add word if pattern exists Post 302936757 by xbin on Friday 27th of February 2015 12:06:47 PM
Old 02-27-2015
Try the following->
Code:
sed '/.*_id .*/s/double/string/' FILE

This User Gave Thanks to xbin For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

grep and sed to find a pattern and add newline

Hello All, I have log file the result from a multithreaded process. So when a process finishes it will write to this log file as 123 rows merged. The issue is sometimes the processess finish at the same time or write to the file at the same time as 123 rows merged.145 rows merged. At... (5 Replies)
Discussion started by: ssikhar
5 Replies

2. Shell Programming and Scripting

Sed : identify a pattern and append a word at the end of a line

Hello to all, On aix, I want to identify a term on a line in a file and then add a word at the end of the line identified. I do not want the word to be added when the line contains the symbol "#". I use the following command, but it deletes the term identified then adds the word. #sed... (4 Replies)
Discussion started by: dantares
4 Replies

3. Shell Programming and Scripting

Sed: add text if pattern not found

Hello, I would like to add the line TIMEZONE="CET" if the pattern TIMEZONE is not found between the range <JOB and JOB> : Example: Src file: <!DOCTYPE DEFTABLE SYSTEM "deftable.dtd"> <DEFTABLE > <JOB TASKTYPE="Job" TIMEFROM="0030" TIMEZONE="CET" </JOB> <JOB... (5 Replies)
Discussion started by: mutunzi
5 Replies

4. Shell Programming and Scripting

How To comment a line where a word exists

Hi All Can u help me.. My problem is comment (#) a line where a word exists in that line sample: cat /tmp/file.txt monitor 192.168.1.11 Copying files in current directory 1 monitor 192.168.1.1 Copying files in current directory 2 monitor 192.168.1.12 Copying files in current... (2 Replies)
Discussion started by: darren_j
2 Replies

5. Shell Programming and Scripting

sed - replacing on the right of a pattern and looking for exact word?

how would you get SED to do the following, say you have the following lines in a text file: user=tigger some text some text some text some text some text some text user=ted some text some text some text some text some text some text user=thekingofrockandroll you want to find any line... (15 Replies)
Discussion started by: rich@ardz
15 Replies

6. UNIX for Dummies Questions & Answers

Mac OS X sed, add newline after pattern

Hi, I've been trying to work out how to add a new line to a file when the pattern matches .dmg. I've been searching Google but yet not found a working solution. Help would be appreciated... (9 Replies)
Discussion started by: pburge
9 Replies

7. Shell Programming and Scripting

Sed/grep: check if line exists, if not add line?

Hello, I'm trying to figure out how to speed up the following as I want to use multiple commands to search thousands of files. is there a way to speed things up? Example I want to search a bunch of files for a specific line, if this line already exists do nothing, if it doesn't exist add it... (4 Replies)
Discussion started by: f77hack
4 Replies

8. Shell Programming and Scripting

sed and awk to find pattern and add priffix

Original File Server1|poweredOn|268401| Server1/Server1.vmx|Red Hat Enterprise Linux 5 (64-bit) Need Output Server1|poweredOn|DR|T1|268401| Server1/Server1.vmx|Red Hat Enterprise Linux 5 (64-bit) Conduction to check find the string "SFCHT1" and "SR" and add prefix has... (4 Replies)
Discussion started by: ranjancom2000
4 Replies

9. UNIX for Beginners Questions & Answers

sed script to delete the last word after a last pattern match

Hi Guys , I am having a file as stated below File 1 sa0 -- i_core/i_core_apb/i_afe0_controller/U261/A sa0 -- i_core/i_core_apb/i_afe0_controller/U265/Z sa1 -- i_core/i_core_apb/i_afe0_controller/U265/A sa1 -- i_core/i_core_apb/i_afe0_controller/U268/Z sa1 -- ... (7 Replies)
Discussion started by: kshitij
7 Replies

10. Shell Programming and Scripting

Extract whole word preceding a specific character pattern with first occurence of the pattern

Hello. Here is a file contents : declare -Ax NEW_FORCE_IGNORE_ARRAY=(="§" ="§" ="§" ="§" ="§" .................. ="§"Here is a pattern =I want to extract 'NEW_FORCE_IGNORE_ARRAY' which is the whole word before the first occurrence of pattern '=' Is there a better solution than mine :... (3 Replies)
Discussion started by: jcdole
3 Replies
MONGOCOMMANDCURSOR.__CONSTRUCT(3)					 1					 MONGOCOMMANDCURSOR.__CONSTRUCT(3)

MongoCommandCursor::__construct - Create a new command cursor

SYNOPSIS
public MongoCommandCursor::__construct (MongoClient $connection, string $ns, array $command = array()) DESCRIPTION
Generally, you should not have to construct a MongoCommandCursor manually, as there are helper functions such as MongoCollection::aggre- gateCursor and MongoCollection::parallelCollectionScan; however, if the server introduces new commands that can return cursors, this con- structor will be useful in the absence of specific helper methods. You may also consider using MongoCommandCursor::createFromDocument. PARAMETERS
o $connection - Database connection. o $ns - Full name of the database and collection (e.g. "test.foo") o $command - Database command. RETURN VALUES
Returns the new cursor. EXAMPLES
Example #1 MongoCommandCursor example <?php $m = new MongoClient; // Define the aggregation pipeline $pipeline = [ [ '$group' => [ '_id' => '$country_code', 'timezones' => [ '$addToSet' => '$timezone' ] ] ], [ '$sort' => [ '_id' => 1 ] ], ]; // Construct a MongoCommandCursor object $cursor = new MongoCommandCursor( $m, // MongoClient object 'demo.cities', // namespace [ 'aggregate' => 'cities', 'pipeline' => $pipeline, 'cursor' => [ 'batchSize' => 0 ], ] ); foreach($cursor as $result) { } ?> SEE ALSO
MongoCommandCursor.createFromDocument(3), MongoCollection.aggregateCursor(3), MongoCollection.parallelCollectionScan(3). PHP Documentation Group MONGOCOMMANDCURSOR.__CONSTRUCT(3)
All times are GMT -4. The time now is 02:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy