Sponsored Content
Top Forums Shell Programming and Scripting Merging files belonging to same date in a directory Post 302115792 by aigles on Friday 27th of April 2007 10:02:23 AM
Old 04-27-2007
You can try ans adapt the following script (mix of perl and shell) :

Code:
perl -e '
        #!/usr/bin/perl -w
        use strict;
        my @infos;
        foreach my $file ( <*> )
        {
           next if ( -d $file ) ;
           my @d = localtime ((stat($file))[9]);
           push @infos, sprintf("%04d.%02d.%02d %02d.%02d.%02d %s\n", $d[5]+1900,$d[4]+1,$d[3],$d[2],$d[1],$d[0],$file);
        }
        
        print sort @infos;
        ' |
while read date time file
do
   printf "%s %s : " $date $time
   if [ "$date" != "$prv_date" ]
   then
      prv_date=$date;
      first_file=$file;
      echo "$file"
   else
      echo "cat $file >> $first_file && rm $file"
   fi
done


Jean-Pierre.

Last edited by aigles; 04-30-2007 at 01:37 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to look in directory for files with diff date

What kind of command can i use to search a directory and subdirectories for all files that do not have the same date? i want to find any files that do not match a date of Sep 13, 2002? Or that have a different owner or group? Any help appreciated! (2 Replies)
Discussion started by: kymberm
2 Replies

2. Shell Programming and Scripting

Creating date directory and moving files into that directory

I have list of files named file_username_051208_025233.log. Here 051208 is the date and 025233 is the time.I have to run thousands of files daily.I want to put all the files depending on the date of running into a date directory.Suppose if we run files today they should put into 05:Dec:08... (3 Replies)
Discussion started by: ravi030
3 Replies

3. Shell Programming and Scripting

How to sort a set of files by date in a directory?

hi there, I have a directory which contents I can parse dynamically. I end up with a file list. I then want to display those files sorted by date, oldest files first. I have very very little PERL experience...Would anyone know how to do that ? Thanks in advance. (8 Replies)
Discussion started by: alexf
8 Replies

4. UNIX for Dummies Questions & Answers

Number of files in a directory modified on a date

Hi How to list all the files in a directory that are modified on a particular date? Also need to know the count,i.e number of files modified on a particular date. Thanks Ashok (1 Reply)
Discussion started by: ashok.k
1 Replies

5. Shell Programming and Scripting

Merging all (48) CSV files from a directory

I have 48 csv files in my directory that all have this form: Storm Speed (mph),43.0410781151 Storm motion direction (degrees),261.580774982 MLCAPE,2450.54098661 MLCIN,-9.85040520279 MLLCL,230 MLLFC,1070.39871 MLEL,207.194689294 MLCT,Not enough data Sbcape,2203.97617778... (3 Replies)
Discussion started by: RissaR
3 Replies

6. Shell Programming and Scripting

Script to move files to a directory according to date

hi all, here is the description to my problem. input parameter: $date1 based on the date i need to select three files starting with audit.log* based on its modified date, a date before, a date after(if its exists). We need to compare the input date to modified date of the file. And then... (3 Replies)
Discussion started by: ashrocks
3 Replies

7. Shell Programming and Scripting

Needs to delete particular date files in a directory

Hi Guys, I need help on deleting particular date files in a directory. I have to delete thousands of files with respect to particular date. Could anyone help on this to delete particular date files at a time? Thanks in Advance (2 Replies)
Discussion started by: teddy2882
2 Replies

8. Shell Programming and Scripting

To get the files in a directory for the given date (User entered date)

Need a ksh script to get the files that were created or modified in a directory on a particular date entered by the user. For example if a directory contains files as below : > ll total 41 -rw-rw-r-- 1 psn psn 199 Aug 23 07:06 psn_roll.sh -rw-rw-r-- 1 psn psn ... (10 Replies)
Discussion started by: ramprabhum
10 Replies

9. UNIX for Dummies Questions & Answers

Rename all Files in a UNIX Directory from one date format to another date format

Hi Unix Gurus, I would like to rename several files in a Unix Directory . The filenames can have more than 1 underscore ( _ ) and the last underscore is always followed by a date in the format mmddyyyy. The Extension of the files can be .txt or .pdf or .xls etc and is case insensitive ie... (1 Reply)
Discussion started by: pchegoor
1 Replies

10. Shell Programming and Scripting

List files with date, create directory, move to the created directory

Hi all, i have a folder, with tons of files containing as following, on /my/folder/jobs/ some_name_2016-01-17-22-38-58_some name_0_0.zip.done some_name_2016-01-17-22-40-30_some name_0_0.zip.done some_name_2016-01-17-22-48-50_some name_0_0.zip.done and these can be lots of similar files,... (6 Replies)
Discussion started by: charli1
6 Replies
GEOIP_DB_GET_ALL_INFO(3)						 1						  GEOIP_DB_GET_ALL_INFO(3)

geoip_db_get_all_info - Returns detailed information about all GeoIP database types

SYNOPSIS
array geoip_db_get_all_info (void ) DESCRIPTION
The geoip_db_get_all_info(3) function will return detailed information as a multi-dimensional array about all the GeoIP database types. This function is available even if no databases are installed. It will simply list them as non-available. The names of the different keys of the returning associative array are as follows: o "available" -- Boolean, indicate if DB is available (see geoip_db_avail(3)) o "description" -- The database description o "filename" -- The database filename on disk (see geoip_db_filename(3)) RETURN VALUES
Returns the associative array. EXAMPLES
Example #1 A geoip_db_get_all_info(3) example This will print the array containing all the information. <?php $infos = geoip_db_get_all_info(); if (is_array($infos)) { var_dump($infos); } ?> The above example will output: array(11) { [1]=> array(3) { ["available"]=> bool(true) ["description"]=> string(21) "GeoIP Country Edition" ["filename"]=> string(32) "/usr/share/GeoIP/GeoIP.dat" } [ ... ] [11]=> array(3) { ["available"]=> bool(false) ["description"]=> string(25) "GeoIP Domain Name Edition" ["filename"]=> string(38) "/usr/share/GeoIP/GeoIPDomain.dat" } } Example #2 A geoip_db_get_all_info(3) example You can use the various constants as keys to get only parts of the information. <?php $infos = geoip_db_get_all_info(); if ($infos[GEOIP_COUNTRY_EDITION]['available']) { echo $infos[GEOIP_COUNTRY_EDITION]['description']; } ?> The above example will output: GeoIP Country Edition PHP Documentation Group GEOIP_DB_GET_ALL_INFO(3)
All times are GMT -4. The time now is 06:50 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy