List all files created today exclude last one


 
Thread Tools Search this Thread
Operating Systems Linux List all files created today exclude last one
# 1  
Old 11-21-2012
List all files created today exclude last one

Hi, ALL
thanks in advance,
i listed all files using this command
Code:
ls -ltr  $(date   +%Y%m%d)*.xml

but i would like to exclude the last one created ;
Best regard
MEROUAN


Moderator's Comments:
Mod Comment Use code tags, thanks.

Last edited by zaxxon; 11-21-2012 at 11:13 AM.. Reason: code tags
# 2  
Old 11-21-2012
Try:
Code:
ls -lt  $(date   +%Y%m%d)*.xml | awk 'NR>1'

This User Gave Thanks to bartus11 For This Post:
# 3  
Old 11-21-2012
hideous, but it works
Code:
ls -ltr $(date   +%Y%m%d)*.xml  | head -$(( $(ls -ltr $(date   +%Y%m%d)*.xml | wc -l) - 1 ))

And Bartus' solution above is infinitely better, reminding me once again that I must go through a good book on awk Smilie
These 2 Users Gave Thanks to Skrynesaver For This Post:
# 4  
Old 11-21-2012
Add ... | sed '$d' to your command.

If the desc order doesn't matter:
Code:
ls -lt "$(date +%Y%m%d)"*.xml | tail -n +1

This User Gave Thanks to radoulov For This Post:
# 5  
Old 11-21-2012
yes it works i use Skrynesaver solution .
THANKS ALL FOR TIME
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to find files created today in a particular directory?

Dear All, I want a Hp Ux command to find out the files created today in a particular directory or mountpoint. Kindly help. Thanks Bhaskar (10 Replies)
Discussion started by: sudiptabhaskar
10 Replies

2. Shell Programming and Scripting

how to list all the files for today in the dir

I am trying following ... ls -ltrh | grep 'Dec 2' but it is displaying files for last year also ..as this dir is full of files from last 3-5 yrs I only want to files for today. e.g . ls -ltrh | grep 'Dec 2' -rw-r----- 1 ajay ajay 0 Dec 2 2010 text23.txt -rw-r----- ... (19 Replies)
Discussion started by: ajaypatil_am
19 Replies

3. Shell Programming and Scripting

check file exists and created today issue

Morning My other issue I have seems very simple but im just not seeing it. I have a script that checks on a remote share to see if the backups for some systems have run. Its as simple as: find /mnt/ukwcs-net-config/WLAN-Controllers/ -mtime -1 -ls | egrep '(cfg)' > wlanlog.txt cut -c 1-92... (4 Replies)
Discussion started by: ltodd2
4 Replies

4. Shell Programming and Scripting

ftp - How to download files which created today?

Hello experts, I have written following script to download files which created today. Unfortunately, it's not working. test.ksh: #Defining variables USR='xxx' PASSWD='yyyy' HT='test.test.com' FILE='S*.pdf' XFILE=$(echo find . -type f -mtime 0) ZFILE=$(echo ls -tR|grep 'Jun 8')... (14 Replies)
Discussion started by: dipeshvshah
14 Replies

5. Shell Programming and Scripting

Calculate Files Created Today

I need to figure out how to get all the files from a certian dir ./123/*sat files and ./230/*sat files and several other directories which have these *sat files in them. I need to calculate how many were created today and how many yesterday from 2:00 pm on the 28th to 2pm on the 29th. It's a... (1 Reply)
Discussion started by: xgringo
1 Replies

6. Shell Programming and Scripting

Files with 0 file size and created today

hi, I am building a script to identify those files created/modified today and with file size 0. I am able to find the files with 0 file size and created/modified in last 24 hrs as shown below but not today (current date), I tried using (touch -t time filenm) but in my version of unix at work it... (7 Replies)
Discussion started by: rushs682
7 Replies

7. UNIX for Dummies Questions & Answers

list the files but exclude the files in subdirectories

If I execute the command "ls -l /export/home/abcde/dev/proj/code/* | awk -F' ' '{print $9}' | cut -d'/' -f6-8" it will list all the files in /export/home/abcde/dev/proj/code/ directory as well as the files in subdirectories also proj/code/test.sh proj/code/test1.c proj/code/unix... (8 Replies)
Discussion started by: shyjuezy
8 Replies

8. UNIX for Dummies Questions & Answers

To list all the files created today with directory path

Hi, Can any one tell the command to list all the files that are created as of today from all the directories? The Command "ls -ltR" is listing all the files. But I want the list of files that has been created as of today along with the directory path:) Thank you in advance.:) Regards,... (4 Replies)
Discussion started by: meetusha.b
4 Replies

9. UNIX for Dummies Questions & Answers

How to list all the files which are not generated today

How to list all the files which are not generated today, and move all the above files to backup dir. (2 Replies)
Discussion started by: redlotus72
2 Replies

10. Shell Programming and Scripting

How to list today's files

Hi, I am trying to list names of only today's files OR say, files which are not older than 1 hour and copy them in 'list.txt' file. I know, :ls > list.txt will list all the files. But, how to list today's files? Any help will be appriciated. (4 Replies)
Discussion started by: berlin_germany
4 Replies
Login or Register to Ask a Question