|
| |||||||||
| Tags: cwd, directory, file, unix shell script, update |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| Get latest updated file from your Current Working Directory
Hi, I am student of BSC.I.T. and wanted to know more about UNIX. So, I am making R&D in unix shell script. So, can anyone explain me how to get the name of the file which is latest updated in that directory? Please give me the command and if possible explain it. |
|
#2
| ||||
| ||||
| Re: Get latest updated file from your Current Working Directory
Hi, I am also new to this UNIX programming and not interested in this. But, if you have interest in this then just try to use of internet and download books regarding it. As it may provide you more knowledge and commands regarding it. Or make search for the commands regarding what you want. You can buy book of Orelly to get more advanced knowledge. Just make use of it. So, that you can be able to know more. |
|
#3
| |||
| |||
| Re: Get latest updated file from your Current Working Directory
Hi, you want to get latest updated file from your current working directory, So if your CWD contains only files and directories. Then you can use following command: Code: cd <your existing folder> filename=$(ls -1t|while read obj do echo $obj break done) echo $filename |
|
#4
| ||||
| ||||
| Re: Get latest updated file from your Current Working Directory
Hi, I am not having that much information in Unix. But as you want to know the latest updated file from your current working directory you can use just following command which will solve your problem I think. Just try this. Code: latestfile=`ls -1tr | tail -n 1` |
|
#5
| |||
| |||
| Re: Get latest updated file from your Current Working Directory
hey, buddy the following line gives u latest updated file (it can be directory also) LATEST_FILE=`ls -1tr | tail -n 1` OR LATEST_FILE=`ls -ltr | tail -1 | tr -s '[:space:]' '[\:*]' | cut -d ":" -f 10` here the LATEST_FILE is a variable which contains latest updated file Last edited by sumy : 10-07-2010 at 03:46 PM. |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "Get latest updated file from your Current Working Directory" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to get the latest icons and folder shading on a updated Nokia N8? | Antariksh | Portable Devices | 5 | 4 Weeks Ago 08:43 PM |
| Current Circuits been updated in Forza Motorsport 4 | Chande | Video Games | 5 | 11-10-2011 12:20 PM |
| Is it possible to run latest video games with my current specification | GoutamB | Monitor & Video Cards | 8 | 05-09-2011 11:18 PM |
| GTA IV latest updated addon | Mario2 | Video Games | 3 | 31-03-2009 11:40 AM |
| How to get current directory | Scott2580 | Software Development | 3 | 11-10-2008 04:40 PM |