Move, unzip, backup


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Move, unzip, backup
# 1  
Old 02-05-2019
Move, unzip, backup

Code:
#!/bin/bash
set -xv
errdir=/apps/awd/RPMSReportParser/dist/error
attach=/apps/awd/rip-optumprod/poller/attach
backup=/apps/awd/rip-optumprod/pollerstage/backup/
log=~/catcher.log

exec >>"$log" 2>&1
date >>"$log"

cd $errdir

for i in *.zip*; do

       cp -p $errdir/"$i" "$backup";
       mv -f $errdir/$i "$attach";
       cd "$attach"
       rename 's/(.*).{15}/$1/' *
       /bin/unzip $attach/"$1" -od "$attach" && rm -f "$1";
       find "$backup" -type f -mtime +10 -name '*.zip*' -print0 | xargs -r0 rm --
done


I'm new at this but

file lands in this directory /apps/awd/ReportParser/dist/error/

I need to move the files that land in there which are like this -
Code:
2161V0WBAWD.zip_20190131170233

to here

Code:
/apps/awd/rip-optumprod/poller/attach

and unzip them.

Backing up and logging etc.

I thought this would be easy but I'm a moron it seems. Any suggestions ?

I get various errors when trying to use unzip and or rename the files with the .zip extensions etc.
Moderator's Comments:
Mod Comment To keep the forums high quality for all users, please take the time to format your posts correctly.

First of all, use Code Tags when you post any code or data samples so others can easily read your code. You can easily do this by highlighting your code and then clicking on the # in the editing menu. (You can also type code tags [code] and [/code] by hand.)



Second, avoid adding color or different fonts and font size to your posts. Selective use of color to highlight a single word or phrase can be useful at times, but using color, in general, makes the forums harder to read, especially bright colors like red.

Third, be careful when you cut-and-paste, edit any odd characters and make sure all links are working property.

This is your sixth infraction for not properly formatting your posts. If you continue to depend on moderators to edit your posts to make them readable (instead of doing it yourself), you may end up being temporarily or permanently banned from this site.

Last edited by Don Cragun; 02-05-2019 at 08:22 PM.. Reason: Add missing CODE tags again.
# 2  
Old 02-05-2019
Quote:
Originally Posted by xgringo
Code:
#!/bin/bash
set -xv
errdir=/apps/awd/RPMSReportParser/dist/error
attach=/apps/awd/rip-optumprod/poller/attach
backup=/apps/awd/rip-optumprod/pollerstage/backup/
log=~/catcher.log

exec >>"$log" 2>&1
date >>"$log"

cd $errdir

for i in *.zip*; do

       cp -p $errdir/"$i" "$backup";
       mv -f $errdir/$i "$attach";
       cd "$attach"
       rename 's/(.*).{15}/$1/' *
       /bin/unzip $attach/"$1" -od "$attach" && rm -f "$1";
       find "$backup" -type f -mtime +10 -name '*.zip*' -print0 | xargs -r0 rm --
done


I'm new at this but

file lands in this directory /apps/awd/ReportParser/dist/error/

I need to move the files that land in there which are like this -
Code:
2161V0WBAWD.zip_20190131170233

to here

Code:
/apps/awd/rip-optumprod/poller/attach

and unzip them.

Backing up and logging etc.

I thought this would be easy but I'm a moron it seems. Any suggestions ?

I get various errors when trying to use unzip and or rename the files with the .zip extensions etc.
Moderator's Comments:
Mod Comment To keep the forums high quality for all users, please take the time to format your posts correctly.

First of all, use Code Tags when you post any code or data samples so others can easily read your code. You can easily do this by highlighting your code and then clicking on the # in the editing menu. (You can also type code tags [code] and [/code] by hand.)



Second, avoid adding color or different fonts and font size to your posts. Selective use of color to highlight a single word or phrase can be useful at times, but using color, in general, makes the forums harder to read, especially bright colors like red.

Third, be careful when you cut-and-paste, edit any odd characters and make sure all links are working property.

This is your sixth infraction for not properly formatting your posts. If you continue to depend on moderators to edit your posts to make them readable (instead of doing it yourself), you may end up being temporarily or permanently banned from this site.
With over 8 years as a member of UNIX.com and having started 20 other threads you aren't that "new at this".

And, as you well know, we have difficulty reading the diagnostic messages that are printed on your screen when you don't show us the exact commands you used and the exact diagnostics that were printed by the system. Without being able to see them we can make lots of wild guesses about what might be going wrong (which wastes our time and yours).

Please show us the diagnostic messages that were printed while your script was running (in CODE tags) and tell us what operating system you're using!

Last edited by Don Cragun; 02-07-2019 at 07:16 AM..
This User Gave Thanks to Don Cragun For This Post:
# 3  
Old 02-06-2019
On top of what Don Cragun already requested, pls. show how you call / run the script, so we know what $1 would expand to.
Why using rename ... * (i.e. rename every file in sight) inside a loop is difficult to understand for me, even more when it seems to rename to one single constant target file name. Without knowing the details, I guess unzip having problems working on the resulting gobbledigook.
How about running the script with the -x (xtrace) option set and posting the results?
This User Gave Thanks to RudiC For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Unzip the .zip file without using unzip utility in UNIX

I have .zip file, i want to list all the files archived in the zip file. unzip utility is not working for me in unix. Please help me resolve this issue Thanks ganesh. (3 Replies)
Discussion started by: Ganesh L
3 Replies

2. Shell Programming and Scripting

Help with Backup Shell Script for Network Device Configuration backup

HI all, im new to shell scripting. need your guidence for my script. i wrote one script and is attached here Im explaining the requirement of script. AIM: Shell script to run automatically as per scheduled and backup few network devices configurations. Script will contain a set of commands... (4 Replies)
Discussion started by: saichand1985
4 Replies

3. Shell Programming and Scripting

rsync backup mode(--backup) Are there any options to remove backup folders on successful deployment?

Hi Everyone, we are running rsync with --backup mode, Are there any rsync options to remove backup folders on successful deployment? Thanks in adv. (0 Replies)
Discussion started by: MVEERA
0 Replies

4. Shell Programming and Scripting

How to Unzip a file using unzip utility for files zipped without zip utility ?

Hi, I need to zip/compress a data file and send to a vendor. The vendor does have only unzip utility and can accept only .ZIP files. I do not have zip utility in my server. How do I zip/compress the file so that it can be deflated using unzip command ? I tried gzip & compress commands, but... (1 Reply)
Discussion started by: Sabari Nath S
1 Replies

5. Shell Programming and Scripting

Unix Script - Move and Unzip Files

Requirement Details: We have a folder named 'Inbound Files' that has many folders in it containing source files that have to be processed by Informatica system. We have zipped files, text files and csv files in those folders that have to be moved (cut and paste) from 'Inbound_Files' folder to... (3 Replies)
Discussion started by: haralebp
3 Replies

6. Shell Programming and Scripting

How to Unzip a .ZIP file in Unix without using unzip cmd..?????

Hi All I have ftped a .ZIP file (zipped using WinZip in Windows) to my Unix server (HP-UX). I don't have unzip cmd available in my curent Unix version Please let me know any cmd in UNIX (other than unzip) using which I can unzip this .ZIP file . Please elaborate on the commands aval and... (5 Replies)
Discussion started by: sureshg_sampat
5 Replies

7. SCO

Backup to SCSI Tape Backup aborts

I am trying to make a full backup of my system using the cpio command. The Tape Unit is a SCSI DDS. The process started fine but after about 30 minutes, it just stopped and showed the following message: 1755 Signal 31 - Core dumped Any idea of what is causing this and how to fix it? ... (4 Replies)
Discussion started by: zionpc
4 Replies

8. UNIX for Dummies Questions & Answers

Check backup file size on backup tape

Hi, I performed backup on tape and I want to append more files to my previous backup on the same backup tape. But before I do that I need to know the backup file size of the first backup I performed so that I know the available size on the backup tape. Can someone help me what command I will use... (0 Replies)
Discussion started by: ayhanne
0 Replies

9. HP-UX

How to Unzip a .ZIP file in Unix without using unzip cmd..?????

Hi All I have ftped a .ZIP file (zipped using WinZip in Windows) to my Unix server (HP-UX). I don't have unzip cmd available in my curent Unix version Please let me know any cmd in UNIX (other than unzip) using which I can unzip this .ZIP file . Please elaborate on the commands aval and... (5 Replies)
Discussion started by: sureshg_sampat
5 Replies
Login or Register to Ask a Question