Sponsored Content
Top Forums Shell Programming and Scripting How to more only the last file in the directory? Post 302180769 by streddy on Tuesday 1st of April 2008 05:33:16 AM
Old 04-01-2008
How to more only the last file in the directory?

Hi ,

I am writing a script to more the last file (output file) in the specified directory.

Things have to be considered is, the output file written has the time of the file been executed. So i cant seem to more the file by just the hour as thr could be more than 1 file within the same hour.

my script:

dir=/opt/SMAW/INTP/bin

$dir/./sm_tool.sh countRows <--- this line will generate an output to read from. this is a dev script so i wont be able to modify it.

more getRows.info-`date '+%d_%m_%y_%H:%M:%S'` | grep 'SAR' | awk -F" " '$3!=0' | grep -v " versionized" >>
/export/home/rtp99/Tariff


output directory:

-rw-r--r-- 1 rtp99 dba 66249 Sep 19 2007 getRows.info-19_09_07_11:16:11
-rw-r--r-- 1 rtp99 dba 66975 Oct 2 2007 getRows.info-02_10_07_09:55:38
-rw-r--r-- 1 rtp99 dba 66975 Oct 19 17:40 getRows.info-19_10_07_17:37:06
-rw-r--r-- 1 rtp99 dba 66975 Oct 25 13:36 getRows.info-25_10_07_13:33:34
-rw-r--r-- 1 rtp99 dba 67701 Dec 5 10:53 getRows.info-05_12_07_10:50:23
-rw-r--r-- 1 rtp99 dba 67701 Jan 2 17:23 getRows.info-02_01_08_17:20:08
-rw-r--r-- 1 rtp99 dba 67701 Jan 17 10:15 getRows.info-17_01_08_10:13:00
-rw-r--r-- 1 rtp99 dba 70121 Feb 15 10:34 getRows.info-15_02_08_10:31:34
-rw-r--r-- 1 rtp99 dba 70121 Mar 14 10:22 getRows.info-14_03_08_10:19:28
-rw-r--r-- 1 rtp99 dba 70121 Mar 26 13:26 getRows.info-26_03_08_13:22:48
-rw-r--r-- 1 rtp99 dba 70121 Apr 1 00:27 getRows.info-01_04_08_00:23:27
-rw-r--r-- 1 rtp99 dba 70121 Apr 1 15:15 getRows.info-01_04_08_15:11:17

pls ur thoughts.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Copying one file at a time from one directory to another directory.

Hi All i want to write a script which could copy one file at a time from one directory to another directory. Scenerio: Let's say i have 100 file in a dirctory,so i want to copy one file at a time to another directory with a sleep statement in between that of 30 secs. please help me... (1 Reply)
Discussion started by: Nikhilindurkar
1 Replies

2. Shell Programming and Scripting

Move a file from windows directory to unix directory

Move a file from windows directory to unix directory, is this possible? if it is, can someone help me on this? Thanks! God bless! (1 Reply)
Discussion started by: kingpeejay
1 Replies

3. Shell Programming and Scripting

File transfer from one directory to another directory in unix

Hi, I have to transfer five files from one directory to another directory in unix with the help of shell scripts. This shell script calling the param file as input parameter. Every day one file will come and fall on my source directory. Remaining files will fall on any one of the day of the... (5 Replies)
Discussion started by: easterraj
5 Replies

4. Shell Programming and Scripting

Move the latest or older File from one directory to another Directory

I Need help for one requirement, I want to move the latest/Older file in the folder to another file. File have the datetimestamp in postfix. Example: Source Directory : \a destination Directory : \a\b File1 : xy_MMDDYYYYHHMM.txt (xy_032120101456.txt) File2: xy_MMDDYYYYHHMM.txt... (1 Reply)
Discussion started by: pp_ayyanar
1 Replies

5. Shell Programming and Scripting

Script which removes files from the first directory if there is a file in the second directory

Script must removes files from the first directory if there is a file with same name in the second directory Script passed to the two directories, it lies with them in one directory: sh script_name dir1 dir2 This is my version, but it does not work :wall: set - $2/* for i do set -... (6 Replies)
Discussion started by: SLAMUL
6 Replies

6. Shell Programming and Scripting

Grepping file names, comparing them to a directory of files, and moving them into a new directory

got it figured out :) (1 Reply)
Discussion started by: sHockz
1 Replies

7. Shell Programming and Scripting

Change to directory and search some file in that directory in single command

I am trying to do the following task : export ENV=aaa export ENV_PATH=$(cd /apps | ls | grep $ENV) However, it's not working. What's the way to change to directory and search some file in that directory in single command Please help. (2 Replies)
Discussion started by: saurau
2 Replies

8. Shell Programming and Scripting

Shell scripting-I need a script which should watch a directory for a file with specific directory

I need a script which should watch a directory for a file with specific directory. If it finds a file in directory, it should search for few specific keyword in the file. if the keyword exists, it should trim string from specific column. The file should be moved to another directory and the a... (8 Replies)
Discussion started by: akashdeepak
8 Replies

9. Shell Programming and Scripting

Shell script cannot create directory and move the file to that directory

I have a script, which is checking if file exists and move it to another directory if then mkdir -p ${LOCL_FILES_DIR}/cool_${Today}/monthly mv report_manual_alloc_rpt_A_I_ASSIGNMENT.${Today}*.csv ${LOCL_FILES_DIR}/cool_${Today}/monthly ... (9 Replies)
Discussion started by: digioleg54
9 Replies

10. UNIX for Beginners Questions & Answers

How to find and get a file in an entire directory with an excluded directory specified?

How to get a file 'zlib.h' in an entire directory with an excluded directory specified lives under that starting directory by using find command, as it failed on: $ find . -name 'zlib.h' -a -ipath 'CHROME.TMP' -prune -o -print it'll just list entirely up (2 Replies)
Discussion started by: abdulbadii
2 Replies
TIFFWriteDirectory(3T)													    TIFFWriteDirectory(3T)

NAME
TIFFWriteDirectory, TIFFRewriteDirectory - write the current directory in an open TIFF file SYNOPSIS
#include <tiffio.h> int TIFFWriteDirectory(TIFF* tif) int TIFFRewriteDirectory(TIFF* tif) DESCRIPTION
TIFFWriteDirectory will write the contents of the current directory to the file and setup to create a new subfile in the same file. Appli- cations only need to call TIFFWriteDirectory when writing multiple subfiles to a single TIFF file. TIFFWriteDirectory is automatically called by TIFFClose and TIFFFlush to write a modified directory if the file is open for writing. The TIFFRewriteDirectory function operates similarly to TIFFWriteDirectory but can be called with directories previously read or written that already have an established location in the file. It will rewrite the directory, but instead of place it at it's old location (as TIFFWriteDirectory would) it will place them at the end of the file, correcting the pointer from the preceeding directory or file header to point to it's new location. This is particularly important in cases where the size of the directory and pointed to data has grown, so it won't fit in the space available at the old location. RETURN VALUES
1 is returned when the contents are successfully written to the file. Otherwise, 0 is returned if an error was encountered when writing the directory contents. DIAGNOSTICS
All error messages are directed to the TIFFError(3T) routine. Error post-encoding before directory write. Before writing the contents of the current directory, any pending data are flushed. This mes- sage indicates that an error occurred while doing this. Error flushing data before directory write. Before writing the contents of the current directory, any pending data are flushed. This mes- sage indicates that an error occurred while doing this. Cannot write directory, out of space. There was not enough space to allocate a temporary area for the directory that was to be written. Error writing directory count. A write error occurred when writing the count of fields in the directory. Error writing directory contents. A write error occurred when writing the directory fields. Error writing directory link. A write error occurred when writing the link to the next directory. Error writing data for field "%s". A write error occurred when writing indirect data for the specified field. Error writing TIFF header. A write error occurred when re-writing header at the front of the file. Error fetching directory count. A read error occurred when fetching the directory count field for a previous directory. This can occur when setting up a link to the directory that is being written. Error fetching directory link. A read error occurred when fetching the directory link field for a previous directory. This can occur when setting up a link to the directory that is being written. SEE ALSO
libtiff(3T), TIFFOpen(3T), TIFFError(3T), TIFFReadDirectory(3T), TIFFSetDirectory(3T) September 26, 2001 TIFFWriteDirectory(3T)
All times are GMT -4. The time now is 02:52 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy