Sponsored Content
Top Forums UNIX for Dummies Questions & Answers reading directory for most recent file? Post 26680 by janr on Thursday 22nd of August 2002 07:18:05 AM
Old 08-22-2002
Some questions

Are you looking for the file which has the most resent filename?
-- If so you can use the sort command, like `ls -1 | sort`

Are you looking for the file which is most resent touched (writing in the file)?
-- If so you can use the ls command, like `ls -rt1 | tail -1`

take care

JanR
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Getting the most recent file

Hi people, Please some help over here. I have logs in a directory, in which I need to get the most recent file in order to put it within other command. The format of the files are loadfiles20090308094339_41 loadfiles20090308094418_42 loadfiles20090308095457_43... (4 Replies)
Discussion started by: cgkmal
4 Replies

2. Shell Programming and Scripting

fatal: cannot open file `TNAME' for reading (No such file or directory)

Hi, I am running this command through a shell script and getting the error mentioned in the subject line: testing.awk -f x.txt TNAME My testing.awk file contains something like ++++++++++++++++++ #!/usr/bin/awk -f BEGIN{ TAB_NAME="INSERT_ONE_" ARGV ; } if ( $1=="JAM_ONE" &&... (1 Reply)
Discussion started by: kunwar
1 Replies

3. UNIX for Dummies Questions & Answers

Reading the dates from a file & moving the files from a directory

Hi All, I am coding for a requirement where I need to read a file & get the values of SUB_DATE. Once the dates are found, i need to move the files based on these dates from one directory to another. ie, this is how it will be in the file, SUB_DATE = 20120608,20120607,20120606,20120606... (5 Replies)
Discussion started by: dsfreddie
5 Replies

4. UNIX for Dummies Questions & Answers

Find most recent file and copy to another directory.

Very new to shell scripting. Not sure if my title is correct but I will try and explain. Directory has 100+ files with this format, " ABCD_ABC_Abc_AB0126.abc ". When a new file gets created, the 16-19 characters in the file name gets incremented by 1. Ex...todays most recent file is... (14 Replies)
Discussion started by: askvip
14 Replies

5. Shell Programming and Scripting

' for reading (No such file or directory) `Solaris_websummary.txt

echo "1.1 Apply latest OS patches;" awk '/1.2 Install/ {P=0} P {print $0} FNR==1{printf("From file %s:\n", FILENAME)} /1.1 Apply/ {P=1}' solarisappsummary.txt solarisdbsummary.txt solaris_websummary.txt echo "1.2 Install TCP Wrappers;" awk '/1.3 Install/ {P=0} P {print $0}... (1 Reply)
Discussion started by: alvinoo
1 Replies

6. Shell Programming and Scripting

How to rename (move) most recent files in directory?

I'm using cygwin32 on Windows. DN is an environment variable pointed at my download directory. This command works to move the single most recent file in my download directory to my current directory: mv "`perl -e '$p = $ARGV; opendir $h, $p or die "cannot opendir $p: $!"; @f = sort { -M $a... (2 Replies)
Discussion started by: siegfried
2 Replies

7. UNIX for Dummies Questions & Answers

' for reading (No such file or directory)

1.1 Solaris 10 8/07 s10s_u4wos_12b SPARC 1.2 Patch: 127714-03 Obsoletes: Requires: 120011-14 Incompatibles: Packages: SUNWsshcu, SUNWsshdu, SUNWsshu Patch: 128253-01 Obsoletes: Requires: Incompatibles: Packages: SUNWsshcu Patch: 126630-01 Obsoletes: Requires: Incompatibles: Packages: SUNWtcsh 1.3... (3 Replies)
Discussion started by: alvinoo
3 Replies

8. Shell Programming and Scripting

How to recursively copy directory only for recent files?

I love the -newerct flag for the Cygwin find command on windows. Can I use "/usr/bin/find . -newerct '3 hours ago'" to conditionally copy a directory tree so that only the files in the directory tree that are younger than 3 hours are copied to my destination directory such that the directory... (4 Replies)
Discussion started by: siegfried
4 Replies

9. Shell Programming and Scripting

Help with reading directory paths with spaces from a file

Hi I want to know how to handle the spaces in the below scenario. I have a file (CON_zip_path_1.txt) which has some directory paths with spaces in directory names . My requirement is to unzip these zip files to another path. Please see the code below and the error. CON_zip_path_1.txt... (4 Replies)
Discussion started by: paul1234
4 Replies

10. UNIX for Beginners Questions & Answers

Reading a file from a different directory in a Bash script

Hi all, Given here under a section of a script I am using. SIMDIR="/home/Ins/forces" cd $SIMDIR for file in `ls *.forces` do basename=`echo $file | sed 's/\.*$//'` extname=`echo $file | sed 's/*\(*\)\.\(.*\)/\2\1/'` echo "Processing file: "$basename python convert.py... (4 Replies)
Discussion started by: Theo Score
4 Replies
CHDIR(2)						      BSD System Calls Manual							  CHDIR(2)

NAME
chdir, fchdir -- change current working directory LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <unistd.h> int chdir(const char *path); int fchdir(int fd); DESCRIPTION
The path argument points to the pathname of a directory. The chdir() function causes the named directory to become the current working directory, that is, the starting point for path searches of pathnames not beginning with a slash, '/'. The fchdir() function causes the directory referenced by fd to become the current working directory, the starting point for path searches of pathnames not beginning with a slash, '/'. In order for a directory to become the current directory, a process must have execute (search) access to the directory. RETURN VALUES
Upon successful completion, a value of 0 is returned. Otherwise, a value of -1 is returned and errno is set to indicate the error. ERRORS
chdir() will fail and the current working directory will be unchanged if one or more of the following are true: [ENOTDIR] A component of the path prefix is not a directory. [ENAMETOOLONG] A component of a pathname exceeded {NAME_MAX} characters, or an entire path name exceeded {PATH_MAX} characters. [ENOENT] The named directory does not exist. [ELOOP] Too many symbolic links were encountered in translating the pathname. [EACCES] Search permission is denied for any component of the path name. [EFAULT] path points outside the process's allocated address space. [EIO] An I/O error occurred while reading from or writing to the file system. fchdir() will fail and the current working directory will be unchanged if one or more of the following are true: [EACCES] Search permission is denied for the directory referenced by the file descriptor. [ENOTDIR] The file descriptor does not reference a directory. [EBADF] The argument fd is not a valid file descriptor. [EPERM] The argument fd references a directory which is not at or below the current process's root directory. SEE ALSO
chroot(2) STANDARDS
The chdir() function conforms to ISO/IEC 9945-1:1990 (``POSIX.1''). HISTORY
The fchdir() function call appeared in 4.2BSD. BSD
December 11, 1993 BSD
All times are GMT -4. The time now is 12:14 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy