Sponsored Content
Full Discussion: Sort & Uniq -u
Top Forums Shell Programming and Scripting Sort & Uniq -u Post 302944743 by Antony Ankrose on Thursday 21st of May 2015 02:28:45 PM
Old 05-21-2015
Thanks for your suggestion

Even if i sort with sort -u, why am i getting sales and Marketing twice ?

Code:
/opt/oracle/work/Antony/Shell_Script> cut -d'|' -f4 emp.1st | sort -u
accounts
admin
marketing
marketing
personnel
production
sales
sales

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

sort/uniq

I have a file: Fred Fred Fred Jim Fred Jim Jim If sort is executed on the listed file, shouldn't the output be?: Fred Fred Fred Fred Jim Jim Jim (3 Replies)
Discussion started by: jimmyflip
3 Replies

2. UNIX for Dummies Questions & Answers

Help with Last,uniq, sort and cut

Using the last, uniq, sort and cut commands, determine how many times the different users have logged in. I know how to use the last command and cut command... i came up with last | cut -f1 -d" " | uniq i dont know if this is right, can someone please help me... thanks (1 Reply)
Discussion started by: jay1228
1 Replies

3. Shell Programming and Scripting

sort and uniq in perl

Does anyone have a quick and dirty way of performing a sort and uniq in perl? How an array with data like: this is bkupArr BOLADVICE_VN this is bkupArr MLT6800PROD2A this is bkupArr MLT6800PROD2A this is bkupArr BOLADVICE_VN_7YR this is bkupArr MLT6800PROD2A I want to sort it... (4 Replies)
Discussion started by: reggiej
4 Replies

4. Shell Programming and Scripting

Sort, Uniq, Duplicates

Input File is : ------------- 25060008,0040,03, 25136437,0030,03, 25069457,0040,02, 80303438,0014,03,1st 80321837,0009,03,1st 80321977,0009,03,1st 80341345,0007,03,1st 84176527,0047,03,1st 84176527,0047,03, 20000735,0018,03,1st 25060008,0040,03, I am using the following in the script... (5 Replies)
Discussion started by: Amruta Pitkar
5 Replies

5. Shell Programming and Scripting

Help with Uniq and sort

The key is first field i want only uniq record for the first field in file. I want the output as or output as Appreciate help on this (4 Replies)
Discussion started by: pinnacle
4 Replies

6. Shell Programming and Scripting

sort & uniq on specific fields problem

Hello; I have the output data set from: egrep -i 'warning| error| fail' /var/adm/syslog/syslog.log Jan 31 12:02:18 fidsrv vmunix: LVM: WARNING: VG 128 0x001000: LV 5: Some I/O requests to this LV are waiting Jan 31 12:02:23 fidsrv vmunix: Asynchronous write failed on LUN (dev=0x100000f)... (3 Replies)
Discussion started by: delphys
3 Replies

7. Shell Programming and Scripting

Sort and uniq after comparision

Hi All, I have a text file with the format shown below. Some of the records are duplicated with the only exception being date (Field 15). I want to compare all duplicate records using subscriber number (field 7) and keep only those records with greater date. ... (1 Reply)
Discussion started by: nua7
1 Replies

8. Shell Programming and Scripting

Sort field and uniq

I have a flatfile A.txt 2012/12/04 14:06:07 |trees|Boards 2, 3|denver|mekong|mekong12 2012/12/04 17:07:22 |trees|Boards 2, 3|denver|mekong|mekong12 2012/12/04 17:13:27 |trees|Boards 2, 3|denver|mekong|mekong12 2012/12/04 14:07:39 |rain|Boards 1|tampa|merced|merced11 How do i sort and get... (3 Replies)
Discussion started by: sabercats
3 Replies

9. Shell Programming and Scripting

Uniq or sort -u or similar only between { }

Hi ! I am trying to remove doubbled entrys in a textfile only between delimiters. Like that example but i dont know how to do that with sort or similar. input: { aaa aaa } { aaa aaa } output: { aaa } { (8 Replies)
Discussion started by: fugitivus
8 Replies

10. UNIX for Dummies Questions & Answers

Uniq and sort -u

Hello all, Need to pick your brains, I have a 10Gb file where each row is a name, I am expecting about 50 names in total. So there are a lot of repetitions in clusters. So I want to do a sort -u file Will it be considerably faster or slower to use a uniq before piping it to sort... (3 Replies)
Discussion started by: senhia83
3 Replies
MONGOCOLLECTION.FINDANDMODIFY(3)					 1					  MONGOCOLLECTION.FINDANDMODIFY(3)

MongoCollection::findAndModify - Update a document and return it

SYNOPSIS
public array MongoCollection::findAndModify (array $query, [array $update], [array $fields], [array $options]) DESCRIPTION
The findAndModify command atomically modifies and returns a single document. By default, the returned document does not include the modi- fications made on the update. To return the document with the modifications made on the update, use the $new option. PARAMETERS
o $query - The query criteria to search for. o $update - The update criteria. o $fields - Optionally only return these fields. o $options - An array of options to apply, such as remove the match document from the DB and return it. +----------------+---------------------------------------------------+ | Option | | | | | | | Description | | | | +----------------+---------------------------------------------------+ | $sort array | | | | | | | Determines which document the operation will | | | modify if the query selects multiple documents. | | | findAndModify will modify the first document in | | | the sort order specified by this argument. | | | | |$remove boolean | | | | | | | Optional if $update field exists. When TRUE, | | | removes the selected document. The default is | | | FALSE. | | | | | $update array | | | | | | | Optional if $remove field exists. Performs an | | | update of the selected document. | | | | | $new boolean | | | | | | | Optional. When TRUE, returns the modified docu- | | | ment rather than the original. The findAndModify | | | method ignores the $new option for remove opera- | | | tions. The default is FALSE. | | | | |$upsert boolean | | | | | | | Optional. Used in conjunction with the $update | | | field. When TRUE, the findAndModify command cre- | | | ates a new document if the query returns no docu- | | | ments. The default is false. In MongoDB 2.2, the | | | findAndModify command returns NULL when upsert is | | | TRUE. | | | | | | | | | | | | | | | | +----------------+---------------------------------------------------+ RETURN VALUES
Returns the original document, or the modified document when $new is set. ERRORS
/EXCEPTIONS Throws MongoResultException on failure. EXAMPLES
Example #1 MongoCollection::findAndModify example <?php $m = new Mongo; $col = $m->selectDB("test")->jobs; $col->insert(array( "name" => "Next promo", "inprogress" => false, "priority" => 0, "tasks" => array( "select product", "add inventory", "do placement"), ) ); $col->insert(array( "name" => "Biz report", "inprogress" => false, "priority" => 1, "tasks" => array( "run sales report", "email report" ) ) ); $col->insert(array( "name" => "Biz report", "inprogress" => false, "priority" => 2, "tasks" => array( "run marketing report", "email report" ) ), array("w" => 1) ); $retval = $col->findAndModify( array("inprogress" => false, "name" => "Biz report"), array('$set' => array('inprogress' => true, "started" => new MongoDate())), null, array( "sort" => array("priority" => -1), "new" => true, ) ); var_dump($retval); ?> The above example will output something similar to: array(6) { ["_id"]=> object(MongoId)#7(1) { ["$id"]=> string(24) "5091b5b244415e8cc3000002" } ["inprogress"]=> bool(true) ["name"]=> string(10) "Biz report" ["priority"]=> int(2) ["started"]=> object(MongoDate)#8(2) { ["sec"]=> int(1351726514) ["usec"]=> int(925000) } ["tasks"]=> array(2) { [0]=> string(20) "run marketing report" [1]=> string(12) "email report" } } Example #2 MongoCollection::findAndModify error handling <?php $m = new Mongo; $col = $m->selectDB("test")->jobs; try { $retval = $col->findAndModify( array("inprogress" => false, "name" => "Next promo"), array('$pop' => array("tasks" => -1)), array("tasks" => array('$pop' => array("stuff"))), array("new" => true) ); } catch(MongoResultException $e) { echo $e->getCode(), " : ", $e->getMessage(), " "; var_dump($e->getDocument()); } ?> The above example will output something similar to: 13097 : exception: Unsupported projection option: $pop array(3) { ["errmsg"]=> string(46) "exception: Unsupported projection option: $pop" ["code"]=> int(13097) ["ok"]=> float(0) } SEE ALSO The MongoDB findAndModify command docs. PHP Documentation Group MONGOCOLLECTION.FINDANDMODIFY(3)
All times are GMT -4. The time now is 05:00 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy