![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to search a keyword within a file using a for loop | lucho_1 | Shell Programming and Scripting | 6 | 03-10-2008 02:57 PM |
| Perl: Search for string on line then search and replace text | Crypto | Shell Programming and Scripting | 4 | 01-04-2008 10:24 AM |
| Search for a pattern from the result of search | boopathi_d | Shell Programming and Scripting | 3 | 12-05-2007 09:54 AM |
| Advanced Search Problems.. Search by User Name | Neo | Post Here to Contact Site Administrators and Moderators | 1 | 05-19-2003 01:28 AM |
| how to get the similar function in while loop or for loop | trynew | Shell Programming and Scripting | 3 | 06-17-2002 12:09 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
|||||
|
Sorry. I forgot to mention this will be a loop.
It means that I will not stop after I found 'abc'. I will need to save it to a file and continue to search another pattern like the last occurence of "ss" and append it to the same file. Basically I need to compare the first 5 charactors of each record and only pick the last occurence of the matched(as long as it matches on the first 5 chars) record.I need to search through the whole file to identify any record that first 5 chars are duplicated and only pick the last record. I hope this helps... ?? |
|
|||||
|
Quote:
Place your "search patterns" in a file say patternfile and search for them in your datafile /usr/xpg4/bin/grep -f patternfile datafile As always you can redirect the output to a file of choice Chill enc. |
|
||||
|
You will get a decent answer if you specify the whole problem, not just the pieces that you think you need.
Can you explain how you are identifying duplicates? For example, it sounds like you need sort. sort allows you to sort on a keyfield and eliminate duplicates in the keyfield. If we knew what was needed we could probably find an answer. |
|
|||||
|
sort command
Sorry about my poor English.
I won't have totally identical records. Maybe two records will be like this: 12345apple 12345pear 12345orange I need to only pick '12345orange' because it's the last one that showed up with duplicated '12345'. I only care first 5 charactors in each row. The whole file will be like the above format. I only care the first 5 charactors in each row. If duplicates happens, I only need to pick the last occurence. If no duplicates, I need to pick that only one. Sort command is a good hint. I am thinking how to utilize it... |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|