Complex File Move


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Complex File Move
# 1  
Old 02-04-2015
Complex File Move

Hello,
This is my first post, so please forgive my obvious lack of UNIX knowledge. I am trying/needing to write a script that follows this functional flow:

1. Access a config file that contains format:

Code:
<directory> <filetype> <daterange> 
<directory> <filetype> <daterange> 
<directory> <filetype> <daterange> 
...

per row, with no limit on the number of rows.

2. Copy these files meeting this criteria to a temp folder and zip them, using the current date/time as the zip file name.

This executable needs to be run daily at midnight (via crontab)?

Thank you for helping me solve this! Smilie

Last edited by rbatte1; 02-05-2015 at 10:31 AM.. Reason: Added CODE tags and correct spelling of crontab
# 2  
Old 02-04-2015
Please show a sample of the filenames, as well as how the date range is specified to help us understand how matching of names to date ranges and file types is done.
# 3  
Old 02-04-2015
What I was thinking the config file would look like is something like this:

Code:
<directory> <filetype> <daterange>

so maybe an example would be like:

Code:
\markdir\ *.csv Feb 04 13:35
\markdir\ *.gz Jan 22 15:50
\markdir\ *.mdl Dec 14 2014
\markdir\ *.tlg Aug 01 2014
\markdir\ *.zdf Mar 05 2013

The dates are listed by mm dd hh:mm if in the current year, and mm dd yyyy if in the previous year. This makes it sort of complex I think. Thank you so much for your help!

---------- Post updated at 06:33 PM ---------- Previous update was at 06:20 PM ----------

I think I can be more clear with this, so let me try Smilie

I need the script to run at 0700, and check multiple directories for newly created files. The directories to check, and extensions therein can be specified by the config file. If newly created files exist, then move them to a temp directory.

So I guess the config file really only needs the directory to look in, and the extension to check.

Example:

Code:
\markdir\ *.csv

So it will check \markdir\ to see if there are any file(s) whose creation date matches the current date.

Is that more clear? I hope I did not make more complexity.

Last edited by rbatte1; 02-05-2015 at 10:32 AM.. Reason: WildBeard83 corrected spelling - RBATTE1 added CODE tags
# 4  
Old 02-05-2015
The find command allows you to define the directory, file name(s), and a newer/older date to compare to. Sometimes you'll need to tweak its parameters a little.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Search the specific content from the complex file

Hi, I have a file with complex data without delimiter, have requirement to fetch the specific record based on some charcters. here is my file data ... (12 Replies)
Discussion started by: Riverstone
12 Replies

2. Programming

How to replace the complex strings from a file using sed or awk?

Dear All, I am having a requirement to find the difference between 2 files and generate a discrepancy report out of it as an html page. I prefer using diff -y file1 file2 since it gives user friendly layout to know any discrepancy in the record and unique records among the 2 file. Here's how it... (12 Replies)
Discussion started by: Badhrish
12 Replies

3. Shell Programming and Scripting

Complex file matching

Hello All, I have two files on which I have to do "pattern" based matching and need to place the records to "Matched" and "Unmatched" output files respectively. Here we go: cat file1 ft , * , *, prem , odacc ftpr , * ,* , prem , odacc ft,aa,*,*,odacc ft,*,*,*,* *,*,*,odacc ... (2 Replies)
Discussion started by: panyam
2 Replies

4. Shell Programming and Scripting

Position of the string in a complex file

I had a similar problem few days back and got this fixed with the below command when I have a file with this format GS*12345***** ST*1******** A* B* E* RMR*123455(This is the unique number to locate this row) F* SE*1*** GE*12345* GS*878787***** ST*2 H* J* RMR*567889(This is the... (9 Replies)
Discussion started by: Muthuraj K
9 Replies

5. Shell Programming and Scripting

Sorting complex file with awk

i have a file ddd.txt its delimiter is : but has , and "" within each column as below and also each line ends with ; I_EP,"29":I_US,"120":I_P_ID,"2020":I_NEW,"600":I_OLD,"400":I_POW,"4.5":I_NAME,"TOM";... (9 Replies)
Discussion started by: blackzinga80
9 Replies

6. Shell Programming and Scripting

Parsing a complex log file

I have a log file that has many SQL statements/queries/blocks and their resultant output (success or failure) added to each of them. I need to pick up all the statements which caused errors and write them to a separate file. On most cases, the SQL statement is a single line, like DROP . And if... (1 Reply)
Discussion started by: exchequer598
1 Replies

7. Shell Programming and Scripting

search 3 file and write to 4th file (a bit complex)

hi buddies; rollbackip.txt:10.14.3.65 2 10.14.3.65 3 ... lookup.txt: ... 10.14.3.65 2 10.14.5.55 1 55 10.14.6.66 1 66 10.14.3.65 3 10.14.7.77 3 77 10.14.8.88 2 88 10.14.9.99 4 99 ... ip-port.txt ... port111 3 10.14.5.55 57 port111 2 10.14.5.55 51 port111 1 10.14.5.55 59 ->... (7 Replies)
Discussion started by: gc_sw
7 Replies

8. Shell Programming and Scripting

Splitting a complex file using awk

I have a file that contains the following format delete from table1; delete from table2; insert into table1 (col1, col2) values (value1, value2)@ insert into table1 (col1, col2) values(value3, value4)@ insert into table2(col1, col2,col3) values(value1, value2, value3)@ etc etc This is... (9 Replies)
Discussion started by: hukcjv
9 Replies

9. Programming

Need to modify contents of file with complex patterns.

hi, my fstab file content is like this along with some other lines: /dev/vg0/var1 /var1 ext3 defaults 0 2 /dev/vg0/flx1 /flx1 ext3 defaults 0 2 /dev/vg0/var /var ext3 defaults 0 1 /dev/vg0/flx /flx ext3 defaults 0 2 I want to remove lines with /dev/vg0/var and... (5 Replies)
Discussion started by: success
5 Replies

10. Shell Programming and Scripting

Complex file count problem

Hi all! I have a question regarding possibilities to do line counts. SEARCH_VAR=TEX rsh $REM_HOST -l $REM_USER "cd $REM_DIR; ls *$SEARCH_VAR* 2> /dev/null" | sort -n | awk 'BEGIN { FS = "-" } ; { print $1"\t"$0 }' Will produce an output on the screen like this: 483 483-SOME-TEXT-1... (1 Reply)
Discussion started by: bbergstrom74
1 Replies
Login or Register to Ask a Question