Tag Archives: France Adam

Help me guys

By teefa

how to print first line of each repeated 2 fields only if i got files like :

Code:

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


to make output like :

Code:

USA|Tony|12:25:22:431
USA|John|14:22:42:981
France|Adam|14:22:42:981
Italy|Tony|18:22:42:212


NOTE! :: they were sorted to get max time up

…read more
Source: FULL ARTICLE at The UNIX and Linux Forums

Help me in this script fast

By teefa

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 ]

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 :

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


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

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.

…read more
Source: FULL ARTICLE at The UNIX and Linux Forums