Sponsored Content
Full Discussion: Date of file
Top Forums UNIX for Dummies Questions & Answers Date of file Post 302761351 by Manueldo on Friday 25th of January 2013 01:19:20 PM
Old 01-25-2013
Quote:
Originally Posted by bipinajith
Have a look at this page for the complete list of test-expression used with if
Code:
[[ -N filename ]] && echo yes || echo no

-N option - True if FILE exists and has been modified since it was last read. I guess this is what you are looking for!
#!/bin/sh
It does not work. It gives me only NO. $3 $4$5$6 my files
file=$1
target=$2
while read line
do
if [ "$line" != "" ]
then
set $line
if [ "$1" = "$target" ]
then
if [ "$2" = ":" ]
then
for i in $3 $4 $5 $6
do
-N i && echo yes || echo no
done
fi
fi
fi
done< $file

---------- Post updated at 01:19 PM ---------- Previous update was at 01:15 PM ----------

I found out whats wrong Smilie thank you for helping Smilie
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Changing Creation Date to a Prespecified Date of a File In Unix

Dear Expert, Is there a command to do that in Unix? In such a way that we don't need to actually "write" or modified the content. -- monkfan (4 Replies)
Discussion started by: monkfan
4 Replies

2. 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

3. Shell Programming and Scripting

finding the previous day date and creating a file with date

Hi guys, I had a scenario... 1. I had to get the previous days date in yyyymmdd format 2. i had to create a file with Date inthe format yyyymmdd.txt format both are different thanks guys in advance.. (4 Replies)
Discussion started by: apple2685
4 Replies

4. UNIX for Dummies Questions & Answers

Delete a row from a file if one column containing a date is greater than the current system date

Hello gurus, I am hoping someone can help me with the required code/script to make this work. I have the following file with records starting at line 4: NETW~US60~000000000013220694~002~~IT~USD~2.24~20110201~99991231~01~01~20101104~... (4 Replies)
Discussion started by: chumsky
4 Replies

5. Shell Programming and Scripting

ksh compare dates INSIDE a file (ie date A is > date B)

In KSH, I am pasting 2 almost identical files together and each one has a date and time on each line. I need to determine if the first instance of the date/time is greater than the 2nd instance of the date/time. If the first instance is greater, I just need to echo that line. I thought I would... (4 Replies)
Discussion started by: right_coaster
4 Replies

6. Shell Programming and Scripting

finding date numeral from file and check the validity of date format

hi there I have file names in different format as below triss_20111117_fxcb.csv triss_fxcb_20111117.csv xpnl_hypo_reu_miplvdone_11172011.csv xpnl_hypo_reu_miplvdone_11-17-2011.csv xpnl_hypo_reu_miplvdone_20111117.csv xpnl_hypo_reu_miplvdone_20111117xfb.csv... (10 Replies)
Discussion started by: manas_ranjan
10 Replies

7. Shell Programming and Scripting

Searching for unknown date inside the file and replace to new date

Hello, Iam a newbies to Shell scripting. Iam trying to replace the date inside the file to new date. is there anyway that we can just use the pattern to search as "..." I have many files want to replace with the same date, and each file contains different date. Thanks for your help. ... (2 Replies)
Discussion started by: Daro
2 Replies

8. UNIX for Dummies Questions & Answers

How to pick the latest file with date as one among the file name.( not exactly present date.)?

i have files like 1)20131112_abc_01.csv and 2)20131113_abc_01.csv and 3)20131113_abc_02.csv when i try to fetch the file in the next day. it shud pick the third file.. plz help me.. and i use `date +"%Y%m%d"` command to fetch..it fetches the current date... (2 Replies)
Discussion started by: applepie
2 Replies

9. Shell Programming and Scripting

Script to determine Date,TotalFile,total size of file based on date

I have file listed like below -rw-r--r--+ 1 test test 17M Nov 26 14:43 test1.gz -rw-r--r--+ 1 test test 0 Nov 26 14:44 test2.gz -rw-r--r--+ 1 test test 0 Nov 27 10:41 test3.gz -rw-r--r--+ 1 test test 244K Nov 27 10:41 test4.gz -rw-r--r--+ 1 test test 17M Nov 27 10:41 test5.gz I... (5 Replies)
Discussion started by: krish2014
5 Replies

10. UNIX for Beginners Questions & Answers

“sed” replace date in text file with current date

We want to call a parameter file (.txt) where my application read dynamic values when the job is triggered, one of such values are below: abc.txt ------------------ Code: line1 line2 line3 $$EDWS_DATE_INSERT=08-27-2019 line4 $$EDWS_PREV_DATE_INSERT=08-26-2019 I am trying to write a... (3 Replies)
Discussion started by: pradeepp
3 Replies
Date::Manip::Obj(3)					User Contributed Perl Documentation				       Date::Manip::Obj(3)

NAME
Date::Manip::Obj - Base class for Date::Manip objects SYNOPSIS
The Date::Manip::Obj class is the base class used for the following Date::Manip classes: Date::Manip::Base Date::Manip::TZ Date::Manip::Date Date::Manip::Delta Date::Manip::Recur This module is not intended to be called directly and performs no useful function by itself. Instead, use the various derived classes which inherit from it. DESCRIPTION
This module contains a set of methods used by all Date::Manip classes listed above. You should be familiar with the Date::Manip::Objects and Date::Manip::Config documentation. In the examples below, Date::Manip::Date objects will be used as examples, but (unless otherwise stated), all of the classes listed above have the same methods, and work in the same fashion. METHODS FOR CREATING OBJECTS
new $date = new Date::Manip::Date; $date = new Date::Manip::Date @opts; $date = new Date::Manip::Date $string; $date = new Date::Manip::Date $string,@opts; In order to create the first Date::Manip object, use any of the forms listed above. They will all create a new Date::Manip::Date object (with new Date::Manip::Base, and Date::Manip::TZ objects embedded in it). The Date::Manip::Date, Date::Manip::Delta, and Date::Manip::Recur classes work in exactly the same way. A set of options (described in the Date::Manip::Config documentation) can be passed to the object to set configuration variables. In addition, a string can be passed in which will be parsed to form the initial date stored in the object. Strings can also be passed in to the Date::Manip::Delta and Date::Manip::Recur objects which will be parsed to form initial values. In all cases, refer to the parse method of the class. $dmt = new Date::Manip::TZ; $dmt = new Date::Manip::TZ @opts; If the first Date::Manip object you need is a Date::Manip::TZ object, use either of the above calls. This will also create a Date::Manip::Base object which will be embedded in the Date::Manip::TZ object. A set of options can be passed in as well, but there is no option for passing in a string. $dmb = new Date::Manip::Base; $dmb = new Date::Manip::Base @opts; If you work with Date::Manip::Base objects directly, no other object will be created. The options can be passed in here as well. Once a Date::Manip::Date object (or any object in any other Date::Manip class) is created, one of calls below should be used in order to preserve cached data in the interest of performance and memory usage. $date = new Date::Manip::Date $obj; $date = new Date::Manip::Date $obj,@opts; $date = new Date::Manip::Date $obj,$string; $date = new Date::Manip::Date $obj,$string,@opts; $obj can be an object from any of the Date::Manip classes, but in the interest of making efficient use of cached data, you should pass in the highest level object available. In other words, you should always pass in a Date::Manip::Date, Date::Manip::Delta, or Date::Manip::Recur object if you have one. In their absence, pass in a Date::Manip::TZ object. Pass in a Date::Manip::Base object only if that is the only Date::Manip object available. The one caveat is if you are working with multiple configurations as described in the Date::Manip::Objects document. In that case, additional care should be taken to make sure that the correct object is passed in. If $obj is a Date::Manip::Date object, these lines can be expressed equivalently as: $date = $obj->new(); $date = $obj->new(@opts); $date = $obj->new($string); $date = $obj->new($string,@opts); If @opts is passed in, new Date::Manip::Base and Date::Manip::TZ objects will be created with the configuration specified, so you should only do this if you explicitly want to work with multiple configurations. If you want to modify an existing configuration, you must use the config method described below. new_config $obj2 = $obj1->new_config(); $obj2 = $obj1->new_config($string); $obj2 = $obj1->new_config($string,@opts); $obj2 = $obj1->new_config(@opts); This creates a new instance with a new Date::Manip::Base object and a separate set of config options (even if no config options are included). new_date new_delta new_recur $date = $obj->new_date(); $date = $obj->new_date($string); $date = $obj->new_date($string,@opts); $date = $obj->new_date(@opts); These create a new instance of the specified object. In this case, $obj can be any of the Date::Manip classes, so a date can be created from a delta: $delta = new Date::Manip::Delta; $date = $delta->new_date(); OTHER METHODS
base $dmb = $obj->base(); This returns the Date::Manip::Base object associated with the given object. config $obj->config($var1,$val1,$var2,$val2,...); This will set the value of any configuration variables. Please refer to the Date::Manip::Config manual for a list of all configuration variables and their description. err $err = $obj->err(); This will return the full error message if the previous operation failed for any reason. $obj->err(1); will clear the error code. is_date is_delta is_recur $flag = $obj->is_date(); Returns 0 or 1, depending on the object. For example, a Date::Manip::Date object returns 1 with the is_date method, and 0 for the other two. tz $dmb = $obj->tz(); This returns the Date::Manip::TZ object associated with the given object. version $vers = $obj->version($flag); This returns the version of Date::Manip. If $flag is passed in, and $obj is not a Date::Manip::Base object, the version and timezone information will be passed back. KNOWN BUGS
None known. 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::Obj(3)
All times are GMT -4. The time now is 01:48 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy