Sponsored Content
Top Forums Shell Programming and Scripting Change new filename with date ?? Post 98517 by sabercats on Wednesday 8th of February 2006 11:06:12 PM
Old 02-09-2006
Hi Jim,
Thanks for replying, my case is not sample as mv or cp . I think Smilie .
Okay here is the problem:
In a directory DATA have alot of file name Perform.mmddyyyy.ID.Log where mm is month, dd is day and yyyy is year like Perform.02072006.1234.Log, Perform.02062006.4321.Log, Perform.02082006.4321.Log ...
Each file is a flat file, separate by a pipe like
ID|Location|Date|Hostname|Age|Sex

Then how I write a ksh shell to find all files in DATA directory which are new in the last 2 weeks, and take only 4 fields
ID|Date|Hostname|Age
then write it in a NEWDATA directory, and the file will be named perform-yyyymmdd.dat

Example:
Perform.02062006.4321.Log have
ID|Location|Date|Hostname|Age|Sex
1|SFO|02/06/2006|hawkeye|35|M
2|LAX|02/06/2006|sf49ers|30|M
3|OAK|02/06/2006|goraiders|27|F
4|PIT|02/06/2006|steeler|35|M

and write to a file name perform-20060206.dat
1|02/06/2006|hawkeye|35
2|02/06/2006|sf49ers|30
3|02/06/2006|goraiders|27
4|02/06/2006|steeler|35

How can you do that ? Thanks for sharing your knowlege .
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Move A File With Same Date,don't Change The Desitination Dir Date

Assume, I created one file three years back and I like to move the file to some other directory with the old date (Creation date)? Is it possible? Explain? (1 Reply)
Discussion started by: jee.ku2
1 Replies

2. Shell Programming and Scripting

gzcat into awk and then change FILENAME and process new FILENAME

I am trying to write a script that prompts users for date and time, then process the gzip file into awk. During the ksh part of the script another file is created and needs to be processed with a different set of pattern matches then I need to combine the two in the end. I'm stuck at the part... (6 Replies)
Discussion started by: timj123
6 Replies

3. Shell Programming and Scripting

Change the filename

I have 100 files in a directory with a.1 a.2 a.3 a.4 How do i remove a. and i need the file names as 1 2 3 4 please help (2 Replies)
Discussion started by: srichunduru
2 Replies

4. Shell Programming and Scripting

Get the oldest date based on date in the filename

I am using ksh93 on Solaris. Ok, this may seem like a simple request at first. I have a directory that contains sets of files with a YYYYMMDD component to the name, along with other files of different filespecs. something like this: 20110501_1.dat 20110501_2.dat 20110501_3.dat... (2 Replies)
Discussion started by: gary_w
2 Replies

5. Shell Programming and Scripting

Change the filename variable value

Hi guys, I have a variable where i am storing the filename (with full path). I just need the value before ".txt". But instead of getting the filename i am getting the contents of the filename. FileName=/appl/data/Input/US/Test.txt a=`awk -F"." '{print $1}' ${FileName}` echo $a... (3 Replies)
Discussion started by: mac4rfree
3 Replies

6. UNIX for Dummies Questions & Answers

How to change date in a filename?

Hi i want to list files based on date and change the date alone in the files in a directory abc20120101.txt xyzxyxz20120101.txt ccc20120201.txt ddd20120301.txt In the above i want to select only files having date 20120101 and rename the date for those files like below abc20111231.txt... (3 Replies)
Discussion started by: Dewdrop
3 Replies

7. Shell Programming and Scripting

Change the content of files but not change the date

I have 100 files in a directory , all the files have a word "error" and they are created in different date . Now I would like to change the word from "error" to "warning" , and keep the date of the files ( that means do not change the file creation date after change the word ) , can advise what can... (0 Replies)
Discussion started by: ust3
0 Replies

8. Shell Programming and Scripting

Change the content of files but not change the date

I have 100 files in a directory , all the files have a word "error" and they are created in different date . Now I would like to change the word from "error" to "warning" , and keep the date of the files ( that means do not change the file creation date after change the word ) , can advise what can... (7 Replies)
Discussion started by: ust3
7 Replies

9. Shell Programming and Scripting

How to append date to filename, but base it on yesterday's date?

Hello, I'd like to write a monthly archive script that archives some logs. But I'd like to do it based on yesterday's date. In other words, I'd like to schedule the script to run on the 1st day of each month, but have the archive filename include the previous month instead. Here's what I... (5 Replies)
Discussion started by: nbsparks
5 Replies

10. UNIX for Beginners Questions & Answers

How to change existing date to current date in a filename?

Suppose i have a list of files in a directory as mentioned below 1. Shankar_04152019_ny.txt 2. Gopi_shan_03122019_mi.txt 3. Siva_mourya_02242019_nd.txt .. . . . . 1000 . Jiva_surya_02282019_nd.txt query : At one shot i want to modify the above all filenames present in one path with... (4 Replies)
Discussion started by: Shankar455
4 Replies
Poet::Manual::Subclassing(3pm)				User Contributed Perl Documentation			    Poet::Manual::Subclassing(3pm)

NAME
Poet::Manual::Subclassing - Customizing Poet with subclasses DESCRIPTION
You can subclass the following Poet classes for your application: Poet::Cache Poet::Conf Poet::Log Poet::Mason Poet::Import and arrange things so that Poet always uses your subclass instead of its default class. Place Poet subclasses under "lib/MyApp/Class.pm" in your environment, where "MyApp" is your app name and "Class" is the class you are subclassing minus the "Poet" prefix. A few of these subclasses are generated for you by "poet new". For example, to subclass "Poet::Cache": package MyApp::Cache; use Poet::Moose; extends 'Poet::Cache'; # put your modifications here 1; (Note: Poet::Moose is Moose plus a few Poet standards. You could also use plain "Moose" here.) Poet will automatically detect, load and use any such subclasses. Internally it uses the app_class environment method whenever it needs a classname, e.g. # Do something with MyApp::Cache or Poet::Cache $poet->app_class('Cache')->... Subclassing Mason As long as you have even a bare-bones "Poet::Mason" subclass, e.g. package MyApp::Mason; use Poet::Moose; extends 'Poet::Mason'; 1; then your Mason subclasses will be autodetected as well, e.g. package MyApp::Mason::Interp; use Moose; extends 'Mason::Interp'; # put your modifications here 1; "poet new" will create the bare-bones subclass for you; it is otherwise harmless. See Mason::Manual::Subclasses for more information. EXAMPLES
Use INI instead of YAML for config files package MyApp::Conf; use Config::INI; use Moose; extends 'Poet::Conf'; override 'read_conf_file' => sub { my ($self, $file) = @_; return Config::INI::Reader->read_file($file); }; Perform tasks before and after each Mason request package MyApp::Mason::Request; use Moose; extends 'Mason::Request'; override 'run' => sub { my $self = shift; # Perform tasks before request my $result = super(); # Perform tasks after request return $result; }; Add Perl code to the top of every compiled component package MyApp::Mason::Compilation; use Moose; extends 'Mason::Compilation'; override 'output_class_header' => sub { return join(" ", super(), 'use Foo;', 'use Bar qw(baz);'); }; Use Log::Dispatch instead of Log4perl for logging package MyApp::Log; use Log::Any::Adapter; use Log::Dispatch; use Moose; extends 'Poet::Log'; override 'initialize_logging' => sub { my $log = Log::Dispatch->new( ... ); Log::Any::Adapter->set('Dispatch', dispatcher => $log); }; Add your own $dbh quick var package MyApp::Import use DBI; use Poet::Moose; extends 'Poet::Import'; method provide_dbh ($caller, $poet) { $dbh = DBI->connect(...); } SEE ALSO
Poet AUTHOR
Jonathan Swartz <swartz@pobox.com> COPYRIGHT AND LICENSE
This software is copyright (c) 2012 by Jonathan Swartz. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. perl v5.14.2 2012-06-05 Poet::Manual::Subclassing(3pm)
All times are GMT -4. The time now is 03:42 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy