Sponsored Content
Top Forums UNIX for Dummies Questions & Answers [Solved] Finding the latest file in a directory Post 302731567 by vbe on Thursday 15th of November 2012 10:50:54 AM
Old 11-15-2012
What OS are you using since your output is not what I would expect?
IMHO using ls without -l should not give the absolute path...
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

finding latest file in Unix

Hi, i want to search a file in the dir , if file exists for todays date print the message that file found or if file does not exist for todays date/ if file not found i want to display message saying that file not found. How to do this. Thx for your help. (2 Replies)
Discussion started by: nick12
2 Replies

2. Shell Programming and Scripting

finding latest file having timestamp on it.....

Hi guys, I have a directory in UNIX having files with the below format, i need to pickup the latest file having recent timestamp embedded on it, then need to rename it to a standard file name. Below is the file format: filename_yyyymmdd.csv, i need to pick the latest and move it with the... (1 Reply)
Discussion started by: kaushik25
1 Replies

3. Shell Programming and Scripting

Copy the latest file from one directory to another

Hi All, I am in the directory a/b/processed the files in this directories are -rw-r--r-- 1 owb users 330 Aug 8 chandantest.txt_08082008 -rw-r--r-- 1 owb users 220 Aug 7 chandantest.txt_07082008 -rw-r--r-- 1 owb users 330 Aug 6... (3 Replies)
Discussion started by: chandancsc
3 Replies

4. Shell Programming and Scripting

Copy the latest file to a directory

Hi Team, I wish to copy the latest file of pattern "MyFile*" to some other location. I need to do all the operation in a single command separated by |. ls -rt <MyFile*> | tail -1 | <copy command>. How can I do? Please help me. Thanks, Kanda (2 Replies)
Discussion started by: spkandy
2 Replies

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

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

7. Shell Programming and Scripting

Finding the Latest file in a Dir

Hi Everyone, I am writing a shell script and I am struck here: I need to find the latest file in a directory depending upon the date. For example: The files in the directory are: Filename_bo_20110619 Filename_bo_20110620 Filename_bo_20110621 Filename_bo_20110622 So here, I want... (2 Replies)
Discussion started by: filter
2 Replies

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

9. Shell Programming and Scripting

Help with finding the latest modified version of a file within directories

I am trying to look into multiple directories and pluck out the latest version of a specific file, regardless of where it sits within the directory structure. Ex: The file is a .xls file and could have a depth within the directory of anywhere from 1-5 Working directory - Folder1... (6 Replies)
Discussion started by: co21ss
6 Replies

10. Shell Programming and Scripting

Finding latest file in dir but getting syntax errors

I believe there are couple of syntax issues in my script, couldn't find them :( can someone help me with fixing it to make it work. cd /abcde/ #get the latest filename excluding subdirs filename=`ls -ltr | grep ^- | tail -1 | awk '{print $8}'` #get system date and file timestamp and... (3 Replies)
Discussion started by: simpltyansh
3 Replies
REALPATH(3)								 1							       REALPATH(3)

realpath - Returns canonicalized absolute pathname

SYNOPSIS
string realpath (string $path) DESCRIPTION
realpath(3) expands all symbolic links and resolves references to '/./', '/../' and extra '/' characters in the input $path and returns the canonicalized absolute pathname. PARAMETERS
o $path - The path being checked. Note Whilst a path must be supplied, the value can be blank or NULL In these cases, the value is interpreted as the current directory. RETURN VALUES
Returns the canonicalized absolute pathname on success. The resulting path will have no symbolic link, '/./' or '/../' components. realpath(3) returns FALSE on failure, e.g. if the file does not exist. Note The running script must have executable permissions on all directories in the hierarchy, otherwise realpath(3) will return FALSE. Note Because PHP's integer type is signed and many platforms use 32bit integers, some filesystem functions may return unexpected results for files which are larger than 2GB. CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 5.3.0 | | | | | | | Prior to this release, if only the last $path | | | component did not exist, realpath(3) would not | | | fail on *BSD systems. realpath(3) now fails in | | | this case. | | | | | 5.2.1 | | | | | | | Prior to this version, realpath(3) returned | | | FALSE if $path is an empty string or NULL. | | | | +--------+---------------------------------------------------+ EXAMPLES
Example #1 realpath(3) example <?php chdir('/var/www/'); echo realpath('./../../etc/passwd'); ?> The above example will output: /etc/passwd Example #2 realpath(3) on Windows On windows realpath(3) will change unix style paths to windows style. <?php echo realpath('/windows/system32'); ?> The above example will output: C:WINDOWSSystem32 SEE ALSO
basename(3), dirname(3), pathinfo(3). PHP Documentation Group REALPATH(3)
All times are GMT -4. The time now is 11:00 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy