Sponsored Content
Top Forums Shell Programming and Scripting If condition to check one file newer than the other - first file name uncertain Post 302331505 by achilles5 on Monday 6th of July 2009 11:48:46 AM
Old 07-06-2009
If condition to check one file newer than the other - first file name uncertain

Dear All,

I'm new to unix scripting. I'm trying to write an utility script which has to check if one file is newer than another one. The condition is I dont know the full name of the first file. I searched google and this forum for any such examples, but couldn't find any or may be I would have missed it.

I wrote this simple check using if, but it is not working.
Code:
if [ /abcd/xyz* -nt /abcd/test.txt ]
then
echo "file found"
else
echo "file not found"

If i give a definite file name, it prints "file found", but when I use an *, even if the file is present it says "file not found"

I will have to use the wildcard charcater * bcoz each time the text following "xyz" is different.

Could anyone please tell me how to fix this.

Your help is much appreciated.

Thanks

Last edited by Yogesh Sawant; 07-10-2009 at 04:27 AM.. Reason: added code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

script to check for a condition inside a file

Hi I am writing a script file which sends the log files along with their size in a folder named log to a file called temp.log using the following cmd: ls -st 190_GSTV_HUX_003QISCGSK026** >> /home/user/temp.log the temp.log looks like this: 16 190_GSTV_HUX_003QISCGSK026_message070321.log ... (11 Replies)
Discussion started by: kiran1112
11 Replies

2. Shell Programming and Scripting

How to script to find the newer date in a text file?

Hi, I have a text file, foo.txt, it looks something like below. In the file there is a line that gives the date in the form of: Mon Jun 15 11:09:31 2008. I need to find which date is the newest and then store certain details of that list data to another file. So, in this sample text file, I... (6 Replies)
Discussion started by: boolean2222
6 Replies

3. Shell Programming and Scripting

Check a condition in cronjob to execute a sh file

Hi, I need to execute a crontab based on a condition where one SH file should be executed only based on the output of a file in a folder. I have written the following cron job which is not working. 00 01 * * * read a < /px/batch/reslut.txt && && sh /px/batch/check.sh where my... (2 Replies)
Discussion started by: shanth_chandra
2 Replies

4. Solaris

Before I delete any file in Unix, How can I check no open file handle is pointing to that file?

I know how to check if any file has a unix process using a file by looking at 'lsof <fullpath/filename>' command. I think using lsof is very expensive. Also to make it accurate we need to inlcude fullpath of the file. Is there another command that can tell if a file has a truely active... (12 Replies)
Discussion started by: kchinnam
12 Replies

5. Shell Programming and Scripting

how to find a file then overwrite with a newer version

This should be a simple script, but can't find one with google search. I just need to find the file that is in many directories, then overwrite that file with a newer version i.e. find file.jar then overwrite with /root/file.jar All I get in searches is substitute text with new test inside... (1 Reply)
Discussion started by: haircat
1 Replies

6. Shell Programming and Scripting

Condition to check whether configuration file is empty or not?

CMD=$(find "${Release_Container}" -iname "${Release_Name}"_Release.txt) for i in `cat $CMD` do if ];then cd ${Sandbox_dir} CMD1=$(find "${Sandbox_dir}"/* -iname "${Release_Name}" -type d | awk -F/ '{print $(NF)}' | head -1 ) if ];then echo -e "################### CHECKOUT START... (2 Replies)
Discussion started by: anuragpgtgerman
2 Replies

7. Shell Programming and Scripting

Perl script, replace file with newer file

Hello, Can you please help me one this: I have two servers: Server A and server B. Every day on 03.00AM in only one on these two servers (randomly)is generated one file, lets say file.txt. I want to copy this file also to the other server. I want to create a perl script that does... (2 Replies)
Discussion started by: arrals_vl
2 Replies

8. Shell Programming and Scripting

Parse tab delimited file, check condition and delete row

I am fairly new to programming and trying to resolve this problem. I have the file like this. CHROM POS REF ALT 10_sample.bam 11_sample.bam 12_sample.bam 13_sample.bam 14_sample.bam 15_sample.bam 16_sample.bam tg93 77 T C T T T T T tg93 79 ... (4 Replies)
Discussion started by: empyrean
4 Replies

9. UNIX for Dummies Questions & Answers

If condition to check one file newer than the other

Dear All, I'm new to unix scripting. I'm trying to write an utility script which has to check if one file is newer than another one. $3 $4 $5 $6 are files .txt. Help me please. for i in $3 $4 $5 $6 do if then echo "$1 is newer than $i" else echo "$i is newer than $1" fi (9 Replies)
Discussion started by: Manueldo
9 Replies

10. Shell Programming and Scripting

Copy file only if newer

I only want the file copied if it is newer. But it still copies the file? zip -u Ubuntu_Documents.zip ./* cp -u Ubuntu_Documents.zip $DOCS_Backup/Ubuntu_Documents_`date +"%Y-%m-%d-%H-%M"`.zip (5 Replies)
Discussion started by: drew77
5 Replies
pfsoutexr(1)						      General Commands Manual						      pfsoutexr(1)

NAME
pfsoutexr - Write images or frames in OpenEXR format SYNOPSIS
pfsoutexr [--compression <method>] [--keep-xyz] (<file> [--frames <range>]) [<file>...] DESCRIPTION
Use this command to write frames in OpenEXR format. Source pfs frames should be piped to the Standard Input. This command can write arbi- trary channels to OpenEXR, color channels XYZ however are specially handled (see option keep-xyz). All tags from pfs stream are stored in an OpenEXR file as String attributes. Tags assigned to channels are stored in the format <chan- nel_name>:<tag_name>, so that pfsinexr can later restore tags in the appropriate channels. The depth channel DEPTH is renamed to Z to keep compatibility with pfsinexr. If the luminance is absolute (tag LUMINANCE set to ABSOLUTE), WhiteLuminance attribute in OpenEXR file is set to 1. Details on the format of the pattern file names, which are used for saving multiple frames, can be found in the manual page of pfsoutppm. --compression <method>, -c <method> Use one the the available compression methods: NO - no compression RLE - run length encoding ZIPS - zlib compression, one scan line at a time ZIP - zlib compression, in blocks of 16 scan lines PIZ - piz-based wavelet compression (default) PXR24 - lossy 24-bit float compression --keep-xyz By default, color channels XYZ from pfs stream are converted to RGB color space and HALF format, which is a standard format for color data in OpenEXR. Since Half format is 16-bit and floating points values used in pfs stream are 32-bit, this conversion causes loss of precision. When keep-xyz option is specified, color channels XYZ are stored as they are without any conversion (32-bit float XYZ channels). Note however, that most OpenEXR applications can recognize only RGB Half format images and can not handle 32-bit XYZ. --fix-halfmax The maximum value that can be stored in OpenEXR file is limited to 65504 if 16-bit HALF float is used (color channels are stored by default in this format unless --keep-xyz switch is specified). If the luminance data is calibrated in absolute values (cd/m^2), pixel values can easily exceed 65504. To avoid clamping large pixel values, pfsoutexr can rescale data to the range that is valid for 16-bit HALF float format when --fix-halfmax switch is specified. If this switch is missing, a warning message is displayed. Scale factor used for rescaling is stored in OpenEXR file as OpenEXR standard attribute WhiteLuminance, so that pfsinexr can later restore the absolute values. EXAMPLES
pfsin memorial.hdr | pfsoutexr memorial.exr Converts from one HDR format to another SEE ALSO
pfsout(1) pfsoutppm(1) pfsinexr(1) BUGS
pfsinexr and pfsoutexr can not take stdin / stdout as an input/output (dash '-' instead of file name). Please report bugs and comments on implementation to the discussion group http://groups.google.com/group/pfstools pfsoutexr(1)
All times are GMT -4. The time now is 12:00 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy