Moving files within particular conditions


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Moving files within particular conditions
# 1  
Old 04-19-2014
Moving files within particular conditions

I have to move some files, in a particoular range time, from transit directory to a final directory.
For example, consider this scenario:

Code:
/folder/pod/transit
 bash-3.00$ ls -lrt
1367962 Mar 18 09:40 30481.20140318094037.file
1372051 Mar 18 09:40 30480.20140318094035.file
1390620 Mar 19 09:40 30479.20140318094033.file
1365162 Mar 20 09:40 30478.20140318094031.file
1372282 Mar 20 09:40 30477.20140318094030.file
1399722 Mar 21 09:40 30476.20140318094028.file
1393661 Mar 22 09:40 30475.20140318093030.file

/folder/pod/final
bash-3.00$ ls -lrt
total 0

which sequence of commands can i use, for obtain this output case ?

CASE A) moving files between Mar 19 and Mar 20
Code:
/folder/pod/transit
 bash-3.00$ ls -lrt
1367962 Mar 18 09:40 30481.20140318094037.file
1372051 Mar 18 09:40 30480.20140318094035.file
1399722 Mar 21 09:40 30476.20140318094028.file
1393661 Mar 22 09:40 30475.20140318093030.file

/folder/pod/final
bash-3.00$ ls -lrt
1390620 Mar 19 09:40 30479.20140318094033.file
1365162 Mar 20 09:40 30478.20140318094031.file
1372282 Mar 20 09:40 30477.20140318094030.file

CASE B) moving files older than Mar 21
Code:
/folder/pod/transit
 bash-3.00$ ls -lrt
1399722 Mar 21 09:40 30476.20140318094028.file
1393661 Mar 22 09:40 30475.20140318093030.file

/folder/pod/final
bash-3.00$ ls -lrt
1367962 Mar 18 09:40 30481.20140318094037.file
1372051 Mar 18 09:40 30480.20140318094035.file
1390620 Mar 19 09:40 30479.20140318094033.file
1365162 Mar 20 09:40 30478.20140318094031.file
1372282 Mar 20 09:40 30477.20140318094030.file

Thanks in advance for your support
# 2  
Old 04-19-2014
Does your find version have the -newerXY test? If not, try to touch one or two reference files and use them for a -newer comparison.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Merge input from two files into one based on conditions

Using Linux (bash), I have two files which contain information about berries. Example: file1.txt: Blueberry blue 14 Raspberry red 12 Blackberry dark 4 file2.txt Blackberry sour 4 3 Blueberry tasty 12 78 Strawberry yummy 33 88 I want to merge these two files into one. The desired... (5 Replies)
Discussion started by: Zooma
5 Replies

2. Shell Programming and Scripting

Need script for making files based on some conditions.

Hi All, I have a text file (code_data.txt) with the followig data. AMAR AB123456 XYZ KIRAN CB789 ABC RAJ CS78890 XYZ KAMESH A33535335 ABC KUMAR MD678894 MAT RITESH SR3535355... (26 Replies)
Discussion started by: ROCK_PLSQL
26 Replies

3. Shell Programming and Scripting

Copy files matching multiple conditions

Hello How do i copy files matching multiple conditions. Requirement is to search files starting with name abc* and def* and created on a particular date or date range given by the user and copy it to the destination folder. i tried with different commands. below one will give the list ,... (5 Replies)
Discussion started by: NarayanaPrakash
5 Replies

4. AIX

Moving Hidden files to normal files

I have a bunch of hidden files in a directory in AIX. I would like to move these hidden files as regular files to another directory. Say i have the following files in directory /x .test~1234~567 .report~5678~123 .find~9876~576 i would like to move them to directory /y as test~1234~567... (10 Replies)
Discussion started by: umesh.narain
10 Replies

5. UNIX for Dummies Questions & Answers

move files that match specific conditions

Hi all, I'm new to this forum and bash scripting. I have the following problem, I need to copy some files (from one dir. to another) whose first 5 numbers (subjects' ID) match the directory names. Here a shortened version of what I'm trying to do: names=(32983_f 35416_f 43579_f) # these are... (6 Replies)
Discussion started by: ada1983
6 Replies

6. Shell Programming and Scripting

Finding files with wc -l results = 1 then moving the files to another folder

Hi guys can you please help me with a script to find files with one row/1 line of content then move the file to another directory my script below runs but nothing happens to the files....Alternatively Ca I get a script to find the *.csv files with "wc -1" results = 1 then create a list of those... (5 Replies)
Discussion started by: Dj Moi
5 Replies

7. UNIX for Dummies Questions & Answers

Moving Multiple files to destination files

I am running a code like this foreach list ($tmp) mv *_${list}.txt ${chart}_${list}.txt #mv: when moving multiple files, last argument must be a directory mv *_${list}.doc ${chart}_${list}.doc #mv: when moving multiple files, last argument must be a... (3 Replies)
Discussion started by: animesharma
3 Replies

8. Shell Programming and Scripting

moving the files in a.txt files to a different directory

HI All, I am coding a shell script which will pick all the .csv files in a particular directoryand write it in to a .txt file, this .txt file i will use as a source in datastage for processing. now after the processing is done I have to move and archive all the files in the .txt file to a... (5 Replies)
Discussion started by: subhasri_2020
5 Replies

9. Shell Programming and Scripting

awk merging files based on 2 complex conditions

1. if the 1st row IDs of input1 (ID1/ID2.....) is equal to any IDNames of input2 print all relevant values together as defined in the output. 2. A bit tricky part is IDno in the output. All we need to do is numbering same kind of letters as 1 (aa of ID1) and different letters as 2 (ab... (4 Replies)
Discussion started by: ruby_sgp
4 Replies

10. UNIX for Dummies Questions & Answers

any script for joining files based on simple conditions

Condition1; If NPID and IndID of both input1 and input2 are same take all the vaues relevant to them and print together as output Condition2; IDNo in output: Take the highly repeated same letter of similar NPID-IndID as *1* Second highly repeated same letter... (0 Replies)
Discussion started by: stateperl
0 Replies
Login or Register to Ask a Question