Sponsored Content
Full Discussion: Identify script please!
Top Forums Shell Programming and Scripting Identify script please! Post 302488576 by bound4h on Monday 17th of January 2011 06:56:53 PM
Old 01-17-2011
For some reason when I use your two lines, it tries to unzip two files because there is a space in the file name. Here is the whole script. I adapted it from an unpacking script, so that I could unzip a folder full of zip files:

Code:
#!/bin/sh

DLDIR=/mnt/HD_a2/files
LOG=/mnt/usb/logs/unzip.log
UNZIP=/opt/bin/unzip-unzip

  # check incoming DLDIR
  for FILE in `find $DLDIR -name "*.zip"`; do
    if [ "$FILE" != "*.zip" ]; then
      # shell-fu to extract to path containing the rar
      #FILENAME=`expr //$FILE : '.*/\(.*\)'`
      #UNPACKDIR=`echo $FILE | sed -e s/$FILENAME//g`
      FILENAME=$(basename $FILE)
      UNPACKDIR=$(dirname $FILE) 
      echo [`date`] Extracting "$FILE" ... >> $LOG

      # unzip file to the directory its sitting in
      $UNZIP "$FILE" -d "$UNPACKDIR" >> /dev/null 2>&1
      echo [`date`] ... done extracting. >> $LOG

      # cleanup - remove the rar file(s)
      # note: match .rar, .r01, .r02 ... etc
      echo [`date`] Removing "$FILENAME and zip files." >> $LOG
      for j in `find "$DLDIR" -name "*.zip"`; do
        rm $j
      done
    fi
  done
  echo [`date`] Done unpacking/extracting \(if any necessary\)... >> $LOG

# fi

exit 0

So if I have /mnt/HD_a2/files/The App.app.zip, then it tries to unzip (and remove) The and App.app.zip which fails. I know there's an easy command but I just don't know how. I have the same issue when I use the original script to unrar files, they cannot have spaces in the filename. Is there also a way to chmod the unzip/unrar FOLDER and its contents to 777 after it unzips/unrars it? Because I have the script running by root, and when I access the files using AFP (under user called nobody) I can't move/delete them.

Thanks for your help!

Last edited by Franklin52; 01-19-2011 at 03:22 AM.. Reason: Please use code tags instead of quote tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to identify the calling script?

Hi, I have two scripts ( /tmp/k1.sh and /tmp/k2.sh ). k1.sh calls the k2.sh . For security reasons, I must be sure that the k2.sh is being called by the k1.sh . Is it possible for the k2.sh identify that it's been called by the k1.sh? I mean, identify the complete path of the k1.sh (... (6 Replies)
Discussion started by: crematoriumm
6 Replies

2. Shell Programming and Scripting

test script to identify SHELL

I am new to BASH and writing a small script to identify the SHELL . #!/bin/bash BASH='/bin/bash' KSH='/bin/ksh' if then echo "it's Bash" else echo "it's not Bash" fi $ bash -x a.sh + BASH=/bin/bash + KSH=/bin/ksh + '' a.sh: line 4: where am I missing . PLease advice . (10 Replies)
Discussion started by: talashil
10 Replies

3. Shell Programming and Scripting

Shell script to identify the number of files and to append data

Hi I am having a question where I have to 1) Identify the number of files in a directory with a specific format and if the count is >1 we need to concatenate those two files into one file and remember that in the second file the header should not be copied. it should be form first file.... (4 Replies)
Discussion started by: pradkumar
4 Replies

4. AIX

Script to identify high CPU usage processes

Hi Guys, I need to write a script capable of identifying when a high cpu utilitzation process. It sounds simple but we are on a AIX 5.3 environment with Virtual CPU's (VP's) and logical CPU's. Please any ideas or tips would be highly appreciated. Thanks. Harby. (6 Replies)
Discussion started by: arizah
6 Replies

5. Shell Programming and Scripting

Using an awk script to identify dupes in two files

Hello, I have two files. File1 or the master file contains two columns separated by a delimiter: a=b b=d e=f g=h File 2 which is the file to be processed has only a single column a h c b What I need is an awk script to identify unique names from file 2 which are not found in the... (6 Replies)
Discussion started by: gimley
6 Replies

6. Shell Programming and Scripting

Script to Identify if folder has a file in it

Hi everyone I am new to the forums. I haven't done much linux myself but I have been asked if I can do the following. Write a linux script that needs to scan a certain folder every x amount of minutes and if there is a file in the folder then it needs to call a different script. Is this... (2 Replies)
Discussion started by: Bosbaba
2 Replies

7. Shell Programming and Scripting

Perl Script to identify files without extension and assign a value

Hi, I have a perl script which is a part of a shell script which read lines from a flat file(which is generated as part of a script after a series of bteq/fexp) and assigns a value for each object in the file based on the type of file name. (i.e extensions like .bteq/.ctl/.ksh etc) For example,... (1 Reply)
Discussion started by: yohasini
1 Replies

8. Shell Programming and Scripting

How to identify whether the script is in Unix format or not ?

Hi All, I have the below scenario in my environment Developers used to copy file from windows to Linux box. Some time on the copied file developers miss to run the dos2unix utility. Because of this script gets failed during the execution. Most of the failures are due to the dos2unix format... (7 Replies)
Discussion started by: kalpeer
7 Replies

9. Shell Programming and Scripting

Identify variables used in the shell script

Hi, Is there any simple way to get/identify the variables that are used in a file and print those variable names. If I have something like this in a file, /$var/temp_dir/${var2}${var3}.log I want to display the variables 'var', 'var2' and 'var3' from that file. I tried something like... (6 Replies)
Discussion started by: pvamsikr
6 Replies

10. Shell Programming and Scripting

Unable to identify error in the script

cat test3.sh #!/bin/sh set -x while getopts ":n:" opt; do case "$opt" in n) host=$OPTARG shift 2 ;; -h ) host=$2 shift 2 ;; *) break ;; esac done; echo "host =... (7 Replies)
Discussion started by: Vishal_dba
7 Replies
zipnote(1)						      General Commands Manual							zipnote(1)

NAME
zipsplit - split a zipfile into smaller zipfiles SYNOPSIS
zipsplit [-t] [-i] [-p] [-s] [-n size] [-r room] [-b path] [-h] [-v] [-L] zipfile ARGUMENTS
zipfile Zipfile to split. OPTIONS
-t Report how many files it will take, but don't make them. -i Make index (zipsplit.idx) and count its size against first zip file. -n size Make zip files no larger than "size" (default = 36000). -r room Leave room for "room" bytes on the first disk (default = 0). -b path Use path for the output zip files. -p Pause between output zip files. -s Do a sequential split even if it takes more zip files. -h Show a short help. -v Show version information. -L Show software license. DESCRIPTION
zipsplit reads a zipfile and splits it into smaller zipfiles. EXAMPLES
To be filled in. BUGS
Does not yet support large (> 2 GB) or split archives. SEE ALSO
zip(1), unzip(1) AUTHOR
Info-ZIP v3.0 of 8 May 2008 zipnote(1)
All times are GMT -4. The time now is 05:52 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy