Sponsored Content
Full Discussion: Dealing with multiple files
Top Forums Shell Programming and Scripting Dealing with multiple files Post 302673103 by kraljic on Tuesday 17th of July 2012 12:43:47 PM
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/
 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
CRON(8) 						      System Manager's Manual							   CRON(8)

NAME
cron - clock daemon SYNOPSIS
auth/cron [-c] DESCRIPTION
Cron executes commands at specified dates and times according to instructions in the files /cron/user/cron. It runs only on an authentica- tion server. Option -c causes cron to create /cron/user and /cron/user/cron for the current user; it can be run from any Plan 9 machine. Blank lines and lines beginning with # in these files are ignored. Entries are lines with fields minute hour day month weekday host command Command is a string, which may contain spaces, that is passed to an rc(1) running on host for execution. The first five fields are integer patterns for minute 0-59 hour 0-23 day of month 1-31 month of year 1-12 day of week 0-6; 0=Sunday The syntax for these patterns is time : '*' | range range : number | number '-' number | range ',' range Each number must be in the appropriate range. Hyphens specify inclusive ranges of valid times; commas specify lists of valid time ranges. To run the job, cron calls host and authenticates remote execution, equivalent to running rx host command (see con(1)). The user's profile is run with $service set to rx. Cron is not a reliable service. It skips commands if it cannot reach host within two minutes, or if the cron daemon is not running at the appropriate time. EXAMPLES
Here is the job that mails system news. % cat /cron/upas/cron # send system news 15 8-17, 21 *** helix /mail/lib/mailnews % SOURCE
/sys/src/cmd/auth/cron.c SEE ALSO
con(1), rc(1) CRON(8)
All times are GMT -4. The time now is 01:13 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy