Dealing with multiple files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Dealing with multiple files
# 1  
Old 07-17-2012
Dealing with multiple files

Korn Shell

I have hundreds of small files like below created every day. A midnight cron job moves them to the location /u04/temp/logs

But sometimes I have to manually move these files based a certain dates or time.

I have two basic requirements

1.Using mv command I want to move all .dat files generated on July 11th to /u04/temp/logs . How can I do that ?

2. Using mv command I want to move all .dat files generated on 12th of July between 13:00 and 18:30? Because of the BETWEEN requrement, I don't think I can use the find command with mtime or mmin?

ls -lrt output


Code:
-rw-r----- 1 aptusr dba 44133888 Jul 11 15:58 paxlcp_33861.dat
-rw-r----- 1 aptusr dba 44324864 Jul 11 16:03 paxlcp_33862.dat
-rw-r----- 1 aptusr dba 44285952 Jul 11 16:08 paxlcp_33863.dat
-rw-r----- 1 aptusr dba 44451840 Jul 11 16:14 paxlcp_33864.dat
-rw-r----- 1 aptusr dba 44388864 Jul 11 16:19 paxlcp_33865.dat
-rw-r----- 1 aptusr dba 44197888 Jul 11 16:24 paxlcp_33866.dat
-rw-r----- 1 aptusr dba 44388352 Jul 11 16:30 paxlcp_33867.dat
-rw-r----- 1 aptusr dba 44098560 Jul 11 16:35 paxlcp_33868.dat
-rw-r----- 1 aptusr dba 44222976 Jul 11 16:40 paxlcp_33869.dat
.
.
.
.
-- Snipped output
-rw-r----- 1 aptusr dba 44370944 Jul 12 17:36 paxlcp_35480.dat
-rw-r----- 1 aptusr dba 44185600 Jul 12 17:41 paxlcp_35481.dat
-rw-r----- 1 aptusr dba 44482048 Jul 12 17:46 paxlcp_35482.dat
-rw-r----- 1 aptusr dba 44135936 Jul 12 17:51 paxlcp_35483.dat
-rw-r----- 1 aptusr dba 44394496 Jul 12 17:56 paxlcp_35484.dat
-rw-r----- 1 aptusr dba 45940224 Jul 12 18:01 paxlcp_35485.dat
-rw-r----- 1 aptusr dba 44166656 Jul 12 18:06 paxlcp_35486.dat
-rw-r----- 1 aptusr dba 44468224 Jul 12 18:11 paxlcp_35487.dat
-rw-r----- 1 aptusr dba 44120064 Jul 12 18:17 paxlcp_35488.dat
-rw-r----- 1 aptusr dba 44072448 Jul 12 18:23 paxlcp_35489.dat

mv /u04/temp/logs/
# 2  
Old 07-17-2012
I don't know if you want to be able to enter a specific time in a script, otherwise you can use find with "between" by combining two time conditions, like
Code:
find . -mtime +1h30m -mtime -4h -print

That will find all files in current directory modified between 1 and a half hour ago and 4 hours ago.
# 3  
Old 07-17-2012
Try this,

Code:
find . -type f -newermt 2012-07-11 ! -newermt 2012-07-12 | xargs mv /u04/temp/logs

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grep strings on multiple files and output to multiple files

Hi All, I want to use egrep on multiple files and the results should be output to multiple files. I am using the below code in my shell script(working in Ksh shell). However with this code I am not attaining the desired results. #!/bin/ksh ( a="/path/file1" b="path/file2" for file in... (4 Replies)
Discussion started by: am24
4 Replies

2. Emergency UNIX and Linux Support

Dealing with XLS file with multiple tabs

Hey Guys , Recently working on a requirement , i had to deal with XLS file with multiple tabs and the requirement was as below : 1. Convert one XLS file with multiple tabs to multiple CSV files. -- As i was working on MAC , so it was quite easy through APPLESCRIPT to deal with this.But... (6 Replies)
Discussion started by: himanshu sood
6 Replies

3. UNIX for Advanced & Expert Users

Shell script for dealing with XLS file with multiple tabs/worksheets

Hey Guys , Recently working on a requirement , i had to deal with XLS file with multiple tabs and the requirement was as below : 1. Convert one XLS file with multiple tabs to multiple CSV files. -- As i was working on MAC , so it was quite easy through APPLESCRIPT to deal with this.But... (2 Replies)
Discussion started by: himanshu sood
2 Replies

4. UNIX for Dummies Questions & Answers

Dealing with Empty files, AWK and Loops

I write this bit of code to calculate the mean and variance for all the files in one directory and print the mean and variance in a separate folder but with the same file name. FILES="data/*" for X in $FILES do name=$(basename $X) awk '{x=$0; s+=$0; n++} END{mean=s/n; for (i in x){ss... (20 Replies)
Discussion started by: A-V
20 Replies

5. Shell Programming and Scripting

awk, multiple files input and multiple files output

Hi! I'm new in awk and I need some help. I have a folder with a lot of files and I need that awk do something in each file and print a new file with the output. The input file name should be modified when I print the outpu files. Thanks in advance for help! :-) ciao (5 Replies)
Discussion started by: gabrysfe
5 Replies

6. Shell Programming and Scripting

Iterating over subdirectories and dealing with files within them

Hello, I am working on a coding project for a class and to test the program I have created, I have come up with 100 different test cases. The program takes four text files as input, so each of the test cases is contained in a folder with four files. I have a folder called 'tests', within which... (1 Reply)
Discussion started by: dpryor
1 Replies

7. UNIX for Dummies Questions & Answers

Using AWK: Extract data from multiple files and output to multiple new files

Hi, I'd like to process multiple files. For example: file1.txt file2.txt file3.txt Each file contains several lines of data. I want to extract a piece of data and output it to a new file. file1.txt ----> newfile1.txt file2.txt ----> newfile2.txt file3.txt ----> newfile3.txt Here is... (3 Replies)
Discussion started by: Liverpaul09
3 Replies

8. Shell Programming and Scripting

Dealing with files with spaces in the name

Hello, I'm a computer science major and I'm having problems dealing with file names with spaces in them. Particularly I'm saving a file name in a variable and then using the variable in a compare function i.e. a='te xt.txt' b='file2.txt' cmp $a $b If anyone could help me with this particular... (10 Replies)
Discussion started by: jakethegreycat
10 Replies

9. Shell Programming and Scripting

Dealing with log files

Hi , My requirement is that i need to search for a number of strings in a log file and print them with line numbers.The search should be date wise. The sample log file is : Jan 17 02:45:34 srim6165 MQSIv500: (UKBRKR1P_B.LZ_ BENCHMARKS)BIP2648E: Message backed out to a queue; node... (6 Replies)
Discussion started by: charudpss
6 Replies

10. Shell Programming and Scripting

perl: When dealing with files that do not exist

I have a process run weekly where I must convert data formats for about thirty files. I read a text file that provides all of the filenames and switch settings. My perl code is: for ($j = 1; $j <= $k; $j++) { open(FIN2,$fin2) || die "open: $!"; do other stuff } Every once in... (2 Replies)
Discussion started by: joeyg
2 Replies
Login or Register to Ask a Question