Visit Our UNIX and Linux User Community


scp files that are 3 days older from remote server-


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting scp files that are 3 days older from remote server-
# 1  
Old 12-08-2012
scp files that are 3 days older from remote server-

hello,
i am trying to get a list of files to be scped from the remote server
by running the below in my local unix server ( note - there is a passwordless connectivity setup made between the local and remote server) and, we use KSH.
---
Code:
ssh $scp_host "find /a/b/c/*/ -iname "$remote_file""  > list.dat

the above pulls all the files that matches the pattern from remote server...but i wanted to pull only the files that are 3 days old from the remote server. how coud i achieve it using the above syntax.
Moderator's Comments:
Mod Comment Please use code tags

Last edited by jim mcnamara; 12-08-2012 at 09:06 PM..
# 2  
Old 12-08-2012
Say today is Dec 8. If by three days ago you mean all find files dated Dec 5 (ls -l output )
then try:
Code:
ssh $scp_host "find /a/b/c/*/ -type f -iname "$remote_file" -ls "  | 
              grep 'Dec 5' | awk '{printf $(NF) }'  > list.dat

# 3  
Old 12-09-2012
Depending on your find version you have quite some date/time evaluation tests (a/c/mtime, newer, a/c/mmin,...) at your disposal, cf. find man page.
# 4  
Old 12-09-2012
jim mcnamara,

in the case you mentioned, i wanted to pull all files from Dec 5th to as of Dec 8th (say current date is Dec 8th) ..i dont need just the Dec5th.

kindly advise me the syntax for the same -
# 5  
Old 12-09-2012
for example, with below command, you can search the files older than 3 days. (with modify time)

Code:
find . -type f -iname "$remote_file" -mtime +3


Previous Thread | Next Thread
Test Your Knowledge in Computers #190
Difficulty: Easy
In computer science, a data type is an attribute of data which informs the compiler or interpreter how the programmer intends to use the data.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

scp of multiple files to remote server

Hello, I would like to scp multiple files to a remote server that requires a password for the process to be completed. I have 30 folders (x_1, x_2 ... x_30), each containing 25 files. What I want to do is scp 1 out of the 25 files (file called bvals) for all my folders to a remote server and... (3 Replies)
Discussion started by: nasia.m
3 Replies

2. Shell Programming and Scripting

Find and delete files and folders which are n days older from one unix server to another unix server

Hi All, Let me know how can i find and delete files from one unix server to another unix server which are 'N' days older. Please note that I need to delete files on remote unix server.So, probably i will need to use sftp, but question is how can i identify files and folders which are 'N'... (2 Replies)
Discussion started by: sachinkl
2 Replies

3. UNIX for Dummies Questions & Answers

Files older than 50 days

Hi All, OS :- HP-UX wm5qa B.11.23 U ia64 1119805695 unlimited-user license I need to search files older than 50 days. I've used following command in order to search desired files, I also discoverd, it's showing today's files as well. Do you have any clue with this ? wmqa1> find .... (4 Replies)
Discussion started by: alok.behria
4 Replies

4. UNIX for Advanced & Expert Users

find files older than 30 days old

Hello, I have a script which finds files in a directory that are older than 30 days and remove them. The problem is that these files are too many and when i run this command: find * -mtime +30 | xargs rm I run this command inside the directory and it returns the error: /usr/bin/find:... (8 Replies)
Discussion started by: omonoiatis9
8 Replies

5. Shell Programming and Scripting

deleting files older than 7 days

Hi Guys, I am new to unix I am looking for a script to delete files older than 7 days but i also want to exclude certain directories (like arch,log .....) and also some files with extensions ( like .ksh, .ch, ..............) Thanks (1 Reply)
Discussion started by: MAYAMAYA0451
1 Replies

6. Solaris

Delete files older than 30 days

Hi all, I want to delete log files with extension .log which are older than 30 days. How to delete those files? Operating system -- Sun solaris 10 Your input is highly appreciated. Thanks in advance. Regards, Williams (2 Replies)
Discussion started by: William1482
2 Replies

7. Shell Programming and Scripting

delete files more than 15 days older

i have to delete files which are older than 15 days or more except the ones in the directory Current and also *.sh files i have found the command for files 15 days or more older find . -type f -mtime +15 -exec ls -ltr {} \; but how to implement the logic to avoid directory Current and also... (3 Replies)
Discussion started by: ali560045
3 Replies

8. UNIX for Dummies Questions & Answers

Delete files older than 30 days

This is driving me crazy. How can I delete files in a specifc directory that are over 30 days old? Thanks in advance. (3 Replies)
Discussion started by: tlphillips
3 Replies

9. UNIX for Dummies Questions & Answers

Removing files older than 7 days

Script help, I need to delete files that are older than 7 days. I do that automatically but I know that a cron job can do the job for me. Any help is greatly appreciated, as you can see, I am a DOS or WINDOWS guy. Little on UNIX. Thanks (3 Replies)
Discussion started by: texasoeb
3 Replies

10. UNIX for Dummies Questions & Answers

How can I delete files older than 7 days?

I will like to write a script that delete all files that are older than 7 days in a directory and it's subdirectories. Can any one help me out witht the magic command or script? Thanks in advance, Odogboly98:confused: (3 Replies)
Discussion started by: odogbolu98
3 Replies

Featured Tech Videos