The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
part of a filename flame_eagle Shell Programming and Scripting 8 02-28-2008 11:18 AM
Find and store files based on FileName and Modified Time edisonantus UNIX for Advanced & Expert Users 2 02-19-2008 02:25 PM
how to move files into different folders based on filename italia5 UNIX for Dummies Questions & Answers 7 08-23-2006 11:04 AM
how to print part of report ? Golive HP-UX 2 06-22-2005 11:29 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-18-2007
sudheshnaiyer sudheshnaiyer is offline
Registered User
  
 

Join Date: Aug 2007
Posts: 12
Report of duplicate files based on part of the filename

I have the files logged in the file system with names in the format of : filename_ordernumber_date_time
eg:

file_1_12012007_1101.txt
file_2_12022007_1101.txt
file_1_12032007_1101.txt

I need to find out all the files that are logged multiple times with same order number. In the above eg, I need to get a

report like:

file_1: Submitted two times at 12012007_1101 , 12032007_1101
  #2 (permalink)  
Old 12-18-2007
shamrock shamrock is offline Forum Advisor  
Registered User
  
 

Join Date: Oct 2007
Location: USA
Posts: 753
Quote:
Originally Posted by sudheshnaiyer View Post
I have the files logged in the file system with names in the format of : filename_ordernumber_date_time
eg:

file_1_12012007_1101.txt
file_2_12022007_1101.txt
file_1_12032007_1101.txt

I need to find out all the files that are logged multiple times with same order number. In the above eg, I need to get a

report like:

file_1: Submitted two times at 12012007_1101 , 12032007_1101


Code:
ls *.txt |
awk -F"_" '{
  split($4, a, ".")
  num[$2]++
  ord[$2]=$3"_"a[1]
} END {
  for (i in ord)
    if (num[i] > 1)
      print "file_"i": Submitted "num[i]" times "ord[i]
}'

Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:59 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0