Sponsored Content
Top Forums UNIX for Advanced & Expert Users how to open a last modified file in a directory Post 302356570 by malcomex999 on Saturday 26th of September 2009 06:01:49 AM
Old 09-26-2009
not a good way but i guess it does what you want...
Code:
 
ls -lrt | awk '/^-/{file=$9}END{print "cat " file}' | sh

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to zip a modified file 15 days before but not scanning my sub directory files

I am using zip -m option to zip my files, but i dont want my sub directories files to be zipped (1 Reply)
Discussion started by: skrish70
1 Replies

2. UNIX for Dummies Questions & Answers

how to retrieve original contents of a modified file (modified using vi)

Made changes to a file using vi editor and saved those changes now realised that the changes are not required How can I get the previous version of the file.i.e the one which was there on which I had made changes (3 Replies)
Discussion started by: novice100
3 Replies

3. Programming

libRmath.so: cannot open shared object file: No such file or directory

% locate Rmath /m/backup/backup/lib/R/include/Rmath.h /usr/lib/R/include/Rmath.h % gcc -g -o stand stand.c -I/usr/lib/R/include/ -lRmath -lm % ./stand ./stand: error while loading shared libraries: libRmath.so: cannot open shared object file: No such file or directory What's the trouble... (6 Replies)
Discussion started by: cdbug
6 Replies

4. UNIX for Dummies Questions & Answers

How to get the latest modified file name in /home directory?

I only know how to list all sub-directories or files in specified directory. I don't know how to order them by modified date, furthermore, I don't know how to get the top one file in the sorted list. Wish you can do me a favor. Thanks in advance! (3 Replies)
Discussion started by: crest.boy
3 Replies

5. Shell Programming and Scripting

Last modified time of the folder is changing when I view the file inside the directory

Hi., Last modified time of the folder is changing when I view the file inside the directory. Here is the test on sample directory. I believe that ls -l commands gives the time detail w.r.t last modified time. Pl. suggest. bash-3.2$ mkdir test bash-3.2$ cd test bash-3.2$ touch myfile.txt... (2 Replies)
Discussion started by: IND123
2 Replies

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

7. Shell Programming and Scripting

to pick the latest file modified in a directory

I wan to pick the latest modified file name and redirect it to a file .. ls -tr | tail -1 >file but this is printing file ins side the filename , can anyone help me out (5 Replies)
Discussion started by: vishwakar
5 Replies

8. Shell Programming and Scripting

Cannot open [No such file or directory]

I am seeking help on one script that I created to celan up database audit files. The error returned is $./clean_audit.sh: /opt/oracle/logs/audit_clean.log: cannot open The same script is working on other 2 or 3 servers. But not working on other 4 servers. All servers are Oracle Linux. Here is... (21 Replies)
Discussion started by: duke0001
21 Replies

9. UNIX for Dummies Questions & Answers

To find the latest modified file in a directory

I am trying to fetch the latest modified file from a directory using the command find . -type f -exec ls -lt \{\} \+ | head | awk '{print $9}' After the O/P, I get the below mentioned error and the command doesnt terminate at all. find: ls terminated by signal 13 find: ls terminated by... (2 Replies)
Discussion started by: Sree10
2 Replies

10. UNIX for Beginners Questions & Answers

Need help with listing file name and modified date on a huge directory

hi, We have a huge directory that ha 5.1 Million files in it. We are trying to get the file name and modified timestamp of the most recent 3 years from this huge directory for a migration project. However, the ls command (background process) to list the file names and timestamp is running for... (2 Replies)
Discussion started by: subbu
2 Replies
CREAT(2)							System Calls Manual							  CREAT(2)

NAME
creat - create a new file SYNOPSIS
#include <sys/types.h> #include <fcntl.h> int creat(const char *name, mode_t mode) DESCRIPTION
This interface is made obsolete by open(2), it is equivalent to open(name, O_WRONLY | O_CREAT | O_TRUNC, mode) Creat creates a new file or prepares to rewrite an existing file called name, given as the address of a null-terminated string. If the file did not exist, it is given mode mode, as modified by the process's mode mask (see umask(2)). Also see chmod(2) for the construction of the mode argument. If the file did exist, its mode and owner remain unchanged but it is truncated to 0 length. The file is also opened for writing, and its file descriptor is returned. NOTES
The mode given is arbitrary; it need not allow writing. This feature has been used in the past by programs to construct a simple, exclu- sive locking mechanism. It is replaced by the O_EXCL open mode, or the advisory locking of the fcntl(2) facility. RETURN VALUE
The value -1 is returned if an error occurs. Otherwise, the call returns a non-negative descriptor that only permits writing. ERRORS
Creat will fail and the file will not be created or truncated if one of the following occur: [ENOTDIR] A component of the path prefix is not a directory. [ENAMETOOLONG] The path name exceeds PATH_MAX characters. [ENOENT] The named file does not exist. [ELOOP] Too many symbolic links were encountered in translating the pathname. (Minix-vmd) [EACCES] Search permission is denied for a component of the path prefix. [EACCES] The file does not exist and the directory in which it is to be created is not writable. [EACCES] The file exists, but it is unwritable. [EISDIR] The file is a directory. [EMFILE] There are already too many files open. [ENFILE] The system file table is full. [ENOSPC] The directory in which the entry for the new file is being placed cannot be extended because there is no space left on the file system containing the directory. [ENOSPC] There are no free inodes on the file system on which the file is being created. [EROFS] The named file resides on a read-only file system. [ENXIO] The file is a character special or block special file, and the associated device does not exist. [EIO] An I/O error occurred while making the directory entry or allocating the inode. [EFAULT] Name points outside the process's allocated address space. SEE ALSO
open(2), write(2), close(2), chmod(2), umask(2). 4th Berkeley Distribution May 22, 1986 CREAT(2)
All times are GMT -4. The time now is 11:44 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy