How to show one occurence of duplicate date?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to show one occurence of duplicate date?
# 1  
Old 12-20-2012
How to show one occurence of duplicate date?

Iam having one variable with a value

Code:
REPORT_MISSING=$(grep -i 'Unable to find an Entry*' cognos_env01_env13_2012-12-20-0111.log | sed 's|Unable to find an Entry for the report \(.*\) in the Security Matrix|\1|g')

This give me value as

Code:
Direct Authorization Error Listing.xml
Health Zipcode HMO plans.xml
Health Zipcode PPO plans.xml
Health Zipcode State CSU plans.xml
Direct Authorization Error Listing.xml
Health Zipcode HMO plans.xml
Health Zipcode PPO plans.xml
Health Zipcode State CSU plans.xml

It is a big log file and will have duplicate entries like it during run time and i just want to get the first occurence of these .xml values.

Required output

Code:
Direct Authorization Error Listing.xml
Health Zipcode HMO plans.xml
Health Zipcode PPO plans.xml
Health Zipcode State CSU plans.xml

I have tried
Code:
uniq

command at the end but its not working.Could someone please advise me how can i proceed with this.
# 2  
Old 12-20-2012
Try this :

Code:
sort file | uniq

# 3  
Old 12-20-2012
Have you tried
Code:
sort -u

This User Gave Thanks to sathyaonnuix For This Post:
# 4  
Old 12-20-2012
Quote:
Originally Posted by Vikram_Tanwar12
Code:
uniq

command at the end but its not working.Could someone please advise me how can i proceed with this.
For uniq file needs to be sorted.

Try at the end...Smilie

Code:
sort | uniq

OR
Code:
sort -u

OR
Code:
awk '!X[$0]++'

This User Gave Thanks to pamu For This Post:
# 5  
Old 12-20-2012
Thanks guys..I was using the
Code:
sort

and
Code:
uniq

in wrong order.It working fine now.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Show the string in date format

Hello guys. how can print the: 20140206 like Fri, Feb 6, 2015 Thank you. (4 Replies)
Discussion started by: Ymir
4 Replies

2. Shell Programming and Scripting

awk to calculate date and show data

data: hostcomment { host_name=myhost01 entry_type=1 comment_id=1 source=0 persistent=1 entry_time=1415723753 expires=0 expire_time=0 author=hpsm comment_data=IM0837437472 } program { modified_host_attributes=1 modified_service_attributes=1 enable_notifications=1... (20 Replies)
Discussion started by: SkySmart
20 Replies

3. Shell Programming and Scripting

awk to sum a column based on duplicate strings in another column and show split totals

Hi, I have a similar input format- A_1 2 B_0 4 A_1 1 B_2 5 A_4 1 and looking to print in this output format with headers. can you suggest in awk?awk because i am doing some pattern matching from parent file to print column 1 of my input using awk already.Thanks! letter number_of_letters... (5 Replies)
Discussion started by: prashob123
5 Replies

4. Shell Programming and Scripting

Print between patterns - first occurence, second occurence etc

I have a file # cat asasas AAAAAA 11 22 33 44 BBBBB NILNILNIL AAAAAA 22 33 44 55 66 77 88 BBBBB NILNILNIL (2 Replies)
Discussion started by: anil510
2 Replies

5. Shell Programming and Scripting

How to show last month date?

Hi Guys, Please somebody give me a hand to show the Month & Year in assigning to a variable and with format "MMMYY" (i.e. Jul11). See below preferred output. I tried using this but it is giving me the current month... date = "`date +%b%y`" Aug11 DESIRED OUTPUT: Jul11 ... (3 Replies)
Discussion started by: pinpe
3 Replies

6. UNIX for Dummies Questions & Answers

Delete lines with duplicate strings based on date

Hey all, a relative bash/script newbie trying solve a problem. I've got a text file with lots of lines that I've been able to clean up and format with awk/sed/cut, but now I'd like to remove the lines with duplicate usernames based on time stamp. Here's what the data looks like 2007-11-03... (3 Replies)
Discussion started by: mattv
3 Replies

7. Shell Programming and Scripting

Show date/time with tail|grep command

Hi, I have a log file without date/time, and I want that everytime tail|grep find something it displays the date/time and the line. I have tried something like this command but without any luck to display the date/time: tail -F catalina.out | sed "s/^/`date `/" | egrep ... (6 Replies)
Discussion started by: julugu
6 Replies

8. Shell Programming and Scripting

grep to show date/time of file the string was found in.

I've seen several examples of grep showing the filename the string was found in, but what I really need is grep to show the file details in long format (like ls -l would). scenario is: grep mobile_number todays_files This will show me the string I'm after & which files they turn up in, but... (2 Replies)
Discussion started by: woodstock
2 Replies

9. UNIX for Dummies Questions & Answers

ls how to not show date

Hello, I'm using ls -laR to print out a list of file and folders. I want to print only the permission, file size and file name. Also, excluding the '.' and '..'. result from ls -laR: total 6 drwxr-xr-x 8 user staff 512 Nov 28 16:17 . drwxr-x--- 16 user staff 1024... (3 Replies)
Discussion started by: minifish
3 Replies

10. Shell Programming and Scripting

How to show yesterday date

HI all, i am a junior learner, can u teach me how to show yesterday time with unix command? thanks! Cloud (1 Reply)
Discussion started by: wind_n_cloud
1 Replies
Login or Register to Ask a Question