Sponsored Content
Full Discussion: Help me in this script fast
Top Forums Shell Programming and Scripting Help me in this script fast Post 302768902 by teefa on Sunday 10th of February 2013 12:36:01 PM
Old 02-10-2013
Help me in this script fast

i have log files that represent names, times and countries,
each name come once in country but may in diff times
i need at end each name visited which country and its [ last time of visit ]


Code:
USA | Tony | 12:25:22:431
Italy | Tony | 09:33:11:212    ****
Italy| John | 08:22:12:349 
France | Adam | 14:22:42:981
Italy | Tony | 08:22:42:212    ****
Italy | Tony | 04:22:42:212   ****
Italy | Tony | 18:22:42:212   ****
USA | Adam | 14:22:42:981

i want the output to be :

Code:
USA | Tony | 12:25:22:431
Italy | Tony | 18:22:42:212  / we discarded other as this is the latest time/ 
Italy| John | 08:22:12:349
France | Adam | 14:22:42:981
USA | Adam | 14:22:42:981

i have tired this code but it take very huge time so help me to get more smarter script or take a little time
Code:
while [1]
do 
for name in file.txt | cut -d/| -f2 | uniq -d 
do 
grep name file.txt | sort -n -k2  | tail -1 >> output.txt 
done 
done

but this script output is


Code:
Italy | Tony | 18:22:42:212   
Italy| John | 08:22:12:349
France | Adam | 14:22:42:981


which is wrong , it only get least day per name.

Last edited by Scrutinizer; 02-10-2013 at 04:16 PM.. Reason: code tags
 

8 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Need help fast

I am trying to reset the IP address on a Unix HP box here in my office and I am stuck in this EM100 mode and cant issue any commands. Any help would be great. By the way I no zero about unix. Thanks (0 Replies)
Discussion started by: zx6ninja
0 Replies

2. UNIX for Dummies Questions & Answers

What's the fast way to delete these files?

Hi, I had this request from user which I completed by using rm for all these files but I am wondering if there was way to finish it faster rather going through one file at a time. Please check attached text file to see file names. Thanks! (4 Replies)
Discussion started by: tonyvirk
4 Replies

3. Solaris

what is that 1 in the instruction!~ (please help fast)

Hi all, make_lofs /.cdrom/<something>/<something> 1 what does this instruction mean? Note:both the "something" are obviously different . I would like to know what that 1 means, the rest of the instruction is clear!! Thanks (6 Replies)
Discussion started by: wrapster
6 Replies

4. Shell Programming and Scripting

Performing fast searching operations with a bash script

Hi, Here is a tough requirement , to be served by bash script. I want to perform 3,00,000 * 10,000 searches. i.e. I have 10,000 doc files and 3,00,000 html files in the file-system. I want to check, which of the doc files are referred in any html files. (ex- <a href="abc.doc">abc</a>)... (3 Replies)
Discussion started by: jitendriya.dash
3 Replies

5. Solaris

How do you ufsrestore the fast way?

hi, on my sol9 box i create my backup using the below command: /usr/sbin/ufsdump 0uf /dev/rmt/0n /u1 /usr/sbin/ufsdump 0uf /dev/rmt/0n /u2 /usr/sbin/ufsdump 0uf /dev/rmt/0n /u3 /usr/sbin/ufsdump 0uf /dev/rmt/0n /u4 now on the new sol10 box, to restore i use this commands: cd /u1... (3 Replies)
Discussion started by: pinoy43v3r
3 Replies

6. Shell Programming and Scripting

Expect script exiting too fast if used without interact.

Hi I'm working on an Expect script that is supposed to log-into a remote server and run some steps and exit. In the script I first spawn a 'ssh' session to the server and then after logging in I 'send' all the necessary steps ( with a '\r' at the end, so that they get automatically executed the... (3 Replies)
Discussion started by: clakkad
3 Replies

7. Shell Programming and Scripting

Small fast question

just to confirm du from sh show sizes as multiples of 512 byte right? (4 Replies)
Discussion started by: Nick1097
4 Replies

8. UNIX for Dummies Questions & Answers

fast sequence extraction

Hi everyone, I have a large text file containing DNA sequences in fasta format as follows: >someseq GAACTTGAGATCCGGGGAGCAGTGGATCTC CACCAGCGGCCAGAACTGGTGCACCTCCAG GCCAGCCTCGTCCTGCGTGTC >another seq GGCATTTTTGTGTAATTTTTGGCTGGATGAGGT GACATTTTCATTACTACCATTTTGGAGTACA >seq3450... (4 Replies)
Discussion started by: Fahmida
4 Replies
GEOIP_COUNTRY_CODE_BY_NAME(3)						 1					     GEOIP_COUNTRY_CODE_BY_NAME(3)

geoip_country_code_by_name - Get the two letter country code

SYNOPSIS
string geoip_country_code_by_name (string $hostname) DESCRIPTION
The geoip_country_code_by_name(3) function will return the two letter country code corresponding to a hostname or an IP address. PARAMETERS
o $hostname - The hostname or IP address whose location is to be looked-up. RETURN VALUES
Returns the two letter ISO country code on success, or FALSE if the address cannot be found in the database. EXAMPLES
Example #1 A geoip_country_code_by_name(3) example This will print where the host example.com is located. <?php $country = geoip_country_code_by_name('www.example.com'); if ($country) { echo 'This host is located in: ' . $country; } ?> The above example will output: This host is located in: US NOTES
Caution Please see http://www.maxmind.com/en/iso3166 for a complete list of possible return values, including special codes. SEE ALSO
geoip_country_code3_by_name(3), geoip_country_name_by_name(3). PHP Documentation Group GEOIP_COUNTRY_CODE_BY_NAME(3)
All times are GMT -4. The time now is 03:52 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy