Shell script to find out 2 last modified files in a folder..PLZ HELP!!!!!!!!!


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell script to find out 2 last modified files in a folder..PLZ HELP!!!!!!!!!
# 1  
Old 02-01-2008
Data Shell script to find out 2 last modified files in a folder..PLZ HELP!!!!!!!!!

hi all,

I need to find out the last 2 modified files in a folder.There is some way by which,we can check the timestamp and find out..??please help this is urgent.

Thanks in Advance

Anju
# 2  
Old 02-01-2008
As simple as

Code:
ls -Atr | tail -2

# 3  
Old 02-01-2008
MySQL

Dear Anju,

to get the timestamp of a file, try this,

ls -l filename|awk '{print $6$7$8}'

then the result will be in the format of MonDDYY
here in the place of YY u'll get the time of the file creation if the file get created within 6 months. if the file got created before 6 months then in the place of YY value will be the year(2007 etc)

Regards,
Pankaj
# 4  
Old 02-01-2008
MySQL

try this also

ls -lt |head -2

Regards,
Pankaj
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Request for Shell script to move files from Subfolder to Parent folder and delete sub folder

Hi Team, I am new to shell script and there is a requirement where files should be moved from Subfolder to parent folder. Eg: parent folder --> /Interface/data/test/IN Sub folder -->/Interface/data/test/IN/Invoice20180607233338 Subfolder will be always with timestamp... (6 Replies)
Discussion started by: srivarun15
6 Replies

2. Shell Programming and Scripting

Shell script to copy files from on folder to another

I am trying to copy files with specific date and name to another folder. I am very new to shell scripting so i am finding it hard to do that. see the sample code i have written below. srcdir="/media/ubuntu/CA52057F5205720D/Users/st4r8_000/Desktop/office work/26 nov"... (13 Replies)
Discussion started by: Aqeel Abbas
13 Replies

3. Shell Programming and Scripting

Shell script that lists files with different owner than the folder

Hello, I'm trying to write a script which is listing files based on different preferences, like filetype or permissions. All is fine, except for one: I want to list files in /home which has a different owner than the home directory it is in. Here is an example: /home/UserA is the directory, and... (10 Replies)
Discussion started by: Zwiebi
10 Replies

4. Shell Programming and Scripting

How to unzip files from folder in shell script (ksh)?

I have a folder (C:\shellprg\input\) containing .CSV, .zip, .gz files. 1] I want to find all .zip/.gz files from folder (C:\shellprg\input\). 2] unzip/uncompress files into the same folder (C:\shellprg\input\) through shell script. I am using below commands for unzip files, unzip <filename>... (2 Replies)
Discussion started by: Poonamol
2 Replies

5. Shell Programming and Scripting

How to Process input files from folder in shell script?

Hi, I want to process all input files available into folder (C:\ShellPrg\InputFile\) Input files are abc.CSV , XYZ.zip (zip of CSV file), PQR.gz (zip of CSV file). I want to check the extension of file, If its .zip/.gz then need to unzip the file as .CSV I want to parse line by line of... (2 Replies)
Discussion started by: Poonamol
2 Replies

6. Shell Programming and Scripting

Compiling all modified Java files in a folder on Unix

Hi all, I have a Unix script that will compile all Java files in a sub folder as follows: find . -name "*.java" -print -exec $JAVA_HOME/bin/javac -cp .:$CLASSPATH '{}' \; I would like to enhance it to only compile those Java files who: 1.) Have no class file 2.) Have a class file... (1 Reply)
Discussion started by: Annorax
1 Replies

7. Shell Programming and Scripting

Find all text files in folder and then copy to a new folder

Hi all, *I use Uwin and Cygwin emulator. I´m trying to search for all text files in the current folder (C/Files) and its sub folders using find -depth -name "*.txt" The above command worked for me, but now I would like to copy all found text files to a new folder (C/Files/Text) with ... (4 Replies)
Discussion started by: cgkmal
4 Replies

8. Shell Programming and Scripting

HOW TO CHECK ONLY .C FILES EXISTS OR NOT IN A FOLDER using IF in C shell script?

Hi friends.. I hav a problem.... I dont know how to check .c files exists r not in a folder using IF in C shell script actually i tried like this if(=~ *.c) even though some .c files or there in the current folder..it is not entering int o the if control statement...... (17 Replies)
Discussion started by: p.hemadrireddy
17 Replies

9. Shell Programming and Scripting

help: find and modified files script

hello all im a newbie in the linux world ..i have just started creating basic scripts in linux ..i am using rhel 5 ..the thing is i wanted to create a find script where i could find the last modified file and directory in the directory given as input by the user and storing the output in a file so... (6 Replies)
Discussion started by: tarunicon
6 Replies

10. Shell Programming and Scripting

shell script to call other files..plz help

Hi all, I have a number of shell script,perl script.. etc in a directory,which i need to execute in some order.Now i need to create a script to call all these files in that order..so that the new script will execute all the files one by one....plz help this is urgent. Thanks In advance Anju (3 Replies)
Discussion started by: anju
3 Replies
Login or Register to Ask a Question