Sponsored Content
Top Forums UNIX for Advanced & Expert Users Reading a file and writing the file name to a param file. Post 302139367 by devtakh on Friday 5th of October 2007 04:38:28 PM
Old 10-05-2007
not sure what exactly are you looking for..if i understood correctly..u may want to do something like this-

for file in adc_earnedpoints*.txt
do
datestr=`echo $file | cut -d. -f2`
new=`echo $file | cut -d. -f1,3`

mv $file $new
#call informatica session with the datestr
done

cheers,
Devaraj Takhellambam
 

10 More Discussions You Might Find Interesting

1. Programming

Reading and Writing file on LAN

Hi gurus I am not a C programmer but I need to read and write files on a computer on LAN using IP address. Suppose on a computer that has an IP 192.168.0.2 Any help or code example. I did in JAVA using URL, but do not know how to do in ANSI-C. In java: ------- URL url = new... (3 Replies)
Discussion started by: lucky001
3 Replies

2. UNIX for Dummies Questions & Answers

Script for reading filelist and preparing param file.

Hi All, Not sure if this would be in a dummies sectiin or advanced. I'm looking for a script if someone has doen something like this. I have list of files - adc_earnedpoints.20070630.txt adc_earnedpoints.20070707.txt adc_earnedpoints.20070714.txt adc_earnedpoints.20070721.txt... (2 Replies)
Discussion started by: thebeginer
2 Replies

3. UNIX for Dummies Questions & Answers

reading ,writing,appending ,manipulating a file.

Hi my prob statement is to create a new file or to append to the 1tst file the followign chages. File 1: txt file. portfolio No a b c d abc 1 Any Any Any charString cds 2 values values values charString efd 3 can can can charString fdg 4 come come come charString... (4 Replies)
Discussion started by: szchmaltz
4 Replies

4. UNIX for Dummies Questions & Answers

Log File Writing and Reading

Hi all, I have the following shell script code which tries to sftp and writes the log into the log file. TestConnection () { echo 'Connection to ' $DESTUSERNAME@$DESTHOSTNAME $SETDEBUG if ]; then rm $SCRIPT ; fi touch $SCRIPT echo "cd" $REMOTEDIR >> $SCRIPT echo "quit" >>... (10 Replies)
Discussion started by: valluvan
10 Replies

5. Programming

I need help with file reading/writing in C

Hello everybody, I'm trying to code a program which makes the following: It sends an ARP request frame and when it gets the reply, extracts the IP address of source and writes it to a .txt file. This is gonna be done with many hosts (with a for() loop), so, the text file would look like... (2 Replies)
Discussion started by: Zykl0n-B
2 Replies

6. Shell Programming and Scripting

Reading data from DataBase and Writing to a file

Hi All, Please help me in writing data to a file in one row. In database there is a column which contains large data which does not fit in the file in one row. The column contains list of paths. I want to write these paths to a file in one row. Please find the code below writes : ... (2 Replies)
Discussion started by: rajeshorpu
2 Replies

7. Shell Programming and Scripting

Searching for Log / Bad file and Reading and writing to a flat file

Need to develop a unix shell script for the below requirement and I need your assistance: 1) search for file.log and file.bad file in a directory and read them 2) pull out "Load_Start_Time", "Data_File_Name", "Error_Type" from log file 4) concatinate each row from bad file as... (3 Replies)
Discussion started by: mlpathir
3 Replies

8. Shell Programming and Scripting

reading a file extracting information writing to a file

Hi I am trying to extract information out of a file but keep getting grep cant open errors the code is below: #bash #extract orders with blank address details # # obtain the current date # set today to the current date ccyymmdd format today=`date +%c%m%d | cut -c24-31` echo... (8 Replies)
Discussion started by: Bruble
8 Replies

9. Shell Programming and Scripting

Reading selected lines from a param file

Hi all, I have a question for the Gurus. I apologize if this has bee shared before but I couldn't find the link. I am trying to read parameters from an external parameter file. What I m trying to achieve is read selected lines from an external parameter file into the script. for eg my param... (4 Replies)
Discussion started by: maverick1947
4 Replies

10. Shell Programming and Scripting

Reading and writing in same file

Hi All, Here is my requirement. I am grepping through the log files and cutting some fields from the file to generate a csv file. Now I have to check if 2nd field is having some fixed value then with the help of 4th field I have to look in same log and run another grep command to retrieve the... (11 Replies)
Discussion started by: kmajumder
11 Replies
Date::Manip::Examples(3)				User Contributed Perl Documentation				  Date::Manip::Examples(3)

NAME
Date::Manip::Examples - examples of how to use Date::Manip DESCRIPTION
This document includes a number of examples on how to do common Date::Manip operations. I will be happy to add new examples over time, and welcome suggestions and examples to include. In most cases, an example will include two different ways of getting the answer. The first way will be using the new (as of 6.00) OO modules. The second will be using the old-style functional interface. It should be noted that any time you want to work with alternate time zones, the OO interface is STRONGLY recommended since the functional interface does not preserve time zone information with the date, and may therefore give incorrect results in some cases. However, working in the time zone of the system should give correct results. It should be noted that, in the examples below, it appears that the OO method takes a lot more lines of code than the functional interface. There are a number of ways to shorten the OO method, but for the examples, I wanted to include all the steps explicitly. PARSING A DATE
Dates can be parsed in practically any form in common usage: OO method $date = new Date::Manip::Date; $err = $date->parse("today"); $err = $date->parse("1st Thursday in June 1992"); $err = $date->parse("05/10/93"); $err = $date->parse("12:30 Dec 12th 1880"); $err = $date->parse("8:00pm December tenth"); Functional $date = ParseDate("today"); $date = ParseDate("1st Thursday in June 1992"); $date = ParseDate("05/10/93"); $date = ParseDate("12:30 Dec 12th 1880"); $date = ParseDate("8:00pm December tenth"); The Date::Manip::Date manual has a list of all valid formats. PARSING AN AMOUNT OF TIME
Amounts of time (referred to as deltas) can also be parsed: OO method $delta = new Date::Manip::Delta; $err = $delta->parse("in 12 hours"); $err = $delta->parse("-0:1:30:0"); $err = $delta->parse("4 business days later"); Functional $delta = ParseDateDelta("in 12 hours"); $delta = ParseDateDelta("-0:1:30:0"); $delta = ParseDateDelta("4 business days later"); TO CALCULATE THE AMOUNT OF TIME BETWEEN TWO DATES
$datestr1 = "Jan 30 1999 13:00 EST"; $datestr2 = "2/Mar/1999 15:30:00 +0500"; OO method $date1 = new Date::Manip::Date; $date2 = $date1->new_date(); $err = $date1->parse($datestr1); $err = $date2->parse($datestr2); To get an exact amount of time between the two dates (expressed only in terms of weeks, days, hours, minutes, seconds), use: $delta = $date1->calc($date2); To get an approximate amount of time (expressed in terms of years, months, weeks, etc. in terms that a human would typically think of), use: $delta = $date1->calc($date2,"approx"); Functional $date1 = ParseDate($string1); $date2 = ParseDate($string2); To get an exact amount: $delta = DateCalc($date1,$date2); and the approximate amount: $delta = DateCalc($date1,$date2,1); The Date::Manip::Calc manual has information about these, and other types of calculations. TO ADD AN AMOUNT OF TIME TO A DATE
To find a second date a given amount of time before or after a first date, use the following: $datestr = "Jan 30 1999 13:00 EST"; $deltastr = "12 hours ago"; $deltastr = "in 3 business days"; OO method $date = new Date::Manip::Date; $delta = $date->new_delta(); $date->parse($datestr); $delta->parse($deltastr); $d = $date->calc($delta); Functional $date = DateCalc($datestr,$deltastr); If the delta is a business delta, it will do a business mode calculation. The Date::Manip::Calc manual has information about these, and other types of calculations. COMPARE TWO DATES
To take two different dates and see which is earlier, do the following: $datestr1 = "Jan 30 1999 13:00 EST"; $datestr2 = "2/Mar/1999 15:30:00 +0500"; OO method $date1 = new Date::Manip::Date; $date2 = $date1->new_date; $date1->parse($datestr1); $date2->parse($datestr2); $date1->cmp($date2); => -1, 0, 1 Functional $date1 = ParseDate($datestr1); $date2 = ParseDate($datestr2); Date_Cmp($date1,$date2); => -1, 0, 1 TO EXTRACT INFORMATION ABOUT A DATE OR DELTA
If you have a date or a delta, you can extract information about them as follows: $datestr = "1:24:08 PM EST Feb 3, 1996"; $deltastr = "12 hours ago"; OO method $date = new Date::Manip::Date; $delta = $date->new_delta(); $date->parse($datestr); $delta->parse($deltastr); $date->printf("It is now %T on %b %e, %Y."); => "It is now 13:24:08 on Feb 3, 1996." $delta->printf("In %hv hours, %mv minutes, %sv seconds"); => "In -12 hours, 0 minutes, 0 seconds"; Functional UnixDate($datestr,"It is now %T on %b %e, %Y."); => "It is now 13:24:08 on Feb 3, 1996." Delta_Format($deltastr,"In %hv hours, %mv minutes, %sv seconds"); => "In -12 hours, 0 minutes, 0 seconds"; The Date::Manip::Date manual contains all of the format codes that can be used to extract information from a date. The Date::Manip::Delta manual contains the codes for a delta. WORKING WITH EPOCH
Date::Manip can easily be used to work with the number of seconds since the epoch (Jan 1, 1970 00:00:00 UTC). If you have a date, and you want to find out how many seconds it is after the epoch, you can do it in the following ways: $datestr = "1999-04-30-15:30:00 EDT"; $secs = 1234567; OO method To find out how many seconds have elapsed on a certain date, you can do the following: $date = new Date::Manip::Date; $err = $date->parse($datestr); $date->printf('%s'); => number of seconds To find out the date that is a certain number of seconds since the epoch, you can use the following: $date = new Date::Manip::Date; $err = $date->parse("epoch $secs"); $date now contains the date wanted (in the local time zone) Functional To find out how many seconds have elapsed: UnixDate($datestr,'%s'); => number of seconds To find the date that is a number of seconds since the epoch: ParseDateString("epoch $secs"); Note that Date::Manip will work with both positive seconds (for dates that have come since the epoch) and negative seconds (for dates that occurred before the epoch). RECURRING EVENTS
To find a list of dates where a recurring event happens (even very complex recurrences), do the following: OO method # To find the 2nd Tuesday of every month from Jan 1 1999 to Apr 30 1999 $recur = new Date::Manip::Recur; $start = $recur->new_date(); $end = $recur->new_date(); $start->parse("Jan 1 1999"); $end->parse("Apr 30 1999"); $recur->parse("0:1*2:2:0:0:0",$start,$end); @date = $recur->dates(); # To find the Monday after Easter in 1997-1999 $recur = new Date::Manip::Recur; $recur->parse("*1997-1999:0:0:0:0:0:0*EASTER,ND1"); @date = $recur->dates(); Functional # To find the 2nd Tuesday of every month from Jan 1 1999 to Apr 30 1999 @date = ParseRecur("0:1*2:2:0:0:0","","Jan 1 1999","Apr 30 1999"); # To find the Monday after Easter in 1997-1999. @date = ParseRecur("*1997-1999:0:0:0:0:0:0*EASTER,ND1"); The Date::Manip::Recur manual contains information about recurring events. WORKING WITH DATES IN ANOTHER LANGUAGE
If you want to work with dates in a language other than English (but you are only working with a single language), do the following: OO method $date = new Date::Manip::Date; $date->config("Language","French","DateFormat","non-US"); $date->parse("1er decembre 1990"); Functional Date_Init("Language=French","DateFormat=non-US"); $date = ParseDate("1er decembre 1990"); The Date::Manip::Config manual has a list of all supported languages (in the section on the Language config variable). The meaning of the DateFormat config variable is also included. WORKING WITH TWO DIFFERENT LANGUAGES
If you want to work with dates in two (or more) languages, it is STRONGLY recommended that you use the OO interface. The functional interface will be much slower since it has to re-initialize a lot of language-specific stuff every time you switch back and forth between languages. OO method $date_eng = new Date::Manip::Date; $date_eng->config("Language","English","DateFormat","US"); $date_fre = new Date::Manip::Date; $date_fre->config("Language","French","DateFormat","non-US"); Use the $date_eng object to do English operations, the $date_fre object to do French operations. Functional If you are working with both French and English dates, you can call the following to switch between them: Date_Init("Language=French","DateFormat=non-US"); Date_Init("Language=English","DateFormat=US"); This is NOT recommended. Use the OO method instead. BUGS AND QUESTIONS
Please refer to the Date::Manip::Problems documentation for information on submitting bug reports or questions to the author. SEE ALSO
Date::Manip - main module documentation LICENSE
This script is free software; you can redistribute it and/or modify it under the same terms as Perl itself. AUTHOR
Sullivan Beck (sbeck@cpan.org) perl v5.12.1 2010-01-12 Date::Manip::Examples(3)
All times are GMT -4. The time now is 05:21 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy