Register
It is currently Fri Oct 31, 2014 3:06 am

Basic script to unzip and then delete files


All times are UTC - 6 hours


Post new topic Reply to topic  [ 2 posts ] 
Author Message
 PostPosted: Wed Jul 10, 2013 10:47 am   

Joined: Wed Jul 10, 2013 10:38 am
Posts: 1
Here is my scripts:

Code:
find . -type f -name '*.zip' | while read FILEFULL; do
    FOLDER=`(dirname $FILEFULL)`
    FILENAME=`(basename $FILEFULL)`
    $(unzip "$FILEFULL" -d "$FOLDER")
    $(rm "$FILEFULL")
done
find . -type d -name '__MACOSX' | while read FILEFULL; do
    $(rm -rf "$FILEFULL")
done


Here is the folder structure in which I'm running this in.
External
contains 3 zip files
Internal
Test
contains 3 zip files
Test 2
contains 3 zip files

When I run this everything works great for the External and Internal/Test folders, but when I get to the Internal/Test 2 folder I get an error. Below is my terminal output. The first 6 lines are the the 3 zips in both the External and Internal/Test folders. The last 6 lines are for the 3 zips in Internal/Test 2. So, 1) What is trigging the "Archive:: command not found" errors?, 2) How do I get it to run in the path with the spaces?

Code:
Qualys.sh: line 24: Archive:: command not found
Qualys.sh: line 24: Archive:: command not found
Qualys.sh: line 24: Archive:: command not found
Qualys.sh: line 24: Archive:: command not found
Qualys.sh: line 24: Archive:: command not found
Qualys.sh: line 24: Archive:: command not found
usage: dirname path
Qualys.sh: line 24: Archive:: command not found
usage: dirname path
Qualys.sh: line 24: Archive:: command not found
usage: dirname path
Qualys.sh: line 24: Archive:: command not found


Thanks in advance


Top
 Profile  
 PostPosted: Wed Jul 10, 2013 5:01 pm   

Joined: Mon Mar 02, 2009 3:03 am
Posts: 550
hi,

parenthesis are useless, here.
command substitutions are useless, here.

always use quotes around variables !


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP