[LUNI] TAR
Jeff Norton
jnorton at dfchicago.com
Wed Nov 7 14:10:02 CST 2001
thanks for the help!!!!!!! I got it working:)
Gerald Guglielmo wrote:
> Hi,
> Ok, here is a slightly more general script. You don't need to know
> the names of the files until you are ready to invoke the script. In the
> example I am calling echo and you can change that to tar or any other
> command you want (remove the quotes too).
>
> odsgug}(g023) cat eko
> #!/usr/local/bin/bash
> for f in $@; do echo "tar -xvf $f";done
>
> Now looking at several cases. First two files: file1 and file2
> odsgug}(g023) ./eko file1 file2
> tar -xvf file1
> tar -xvf file2
> next try 5 files set7 set8 set9 set10 and set11
> odsgug}(g023) ./eko set7 set8 set9 set10 set11
> tar -xvf set7
> tar -xvf set8
> tar -xvf set9
> tar -xvf set10
> tar -xvf set11
> finally no files specified:
> odsgug}(g023) ./eko
> odsgug}(g023)
>
> So the keys here are the for loop and the special parameter $@. See the
> man pages for bash.
>
>
> Jeff Norton wrote:
>
>>the other problem I have with this is that I don't know the file names
>>until I receive them and I don't know how many there will be. I need to
>>write a loop but I am not to familiar with BASH scripting
>>
>>Process
>>
>>Goto dir
>>untar file
>>move untar file to another dir
>>delete tar file
>>
>>goto next tar archive
>>
>>repeat process until all files are untar'd, moved and tar archives are
>>deleted
>>
>>Gerald Guglielmo wrote:
>>
>>
>>>Jeff Norton wrote:
>>>
>>>
>>>>I need to write a script that will untar several files. I can't hardcode
>>>>the file names in the script because they will change. Any ideas?
>>>>
>>>>Jeff Norton
>>>>
>>>>______________________________________________________________________
>>>>Linux Users Of Northern Illinois - Technical Discussion
>>>>luni at luni.org
>>>>http://luni.org/mailman/listinfo/luni
>>>>
>>>>
>>>Why not pass in the file names as command line options? Here is a very
>>>simple example that echoes back the file names:
>>>
>>>#!/bin/sh
>>>echo "the script is invoked as $0"
>>>echo "tar -xvf $1"
>>>echo "tar -xvf $2"
>>>exit 0
>>>
>>>bash-2.04$ ./eko file1 file2
>>>the script is invoked as ./eko
>>>tar -xvf file1
>>>tar -xvf file2
>>>
>>>
>>>
>>>
>>______________________________________________________________________
>>Linux Users Of Northern Illinois - Technical Discussion
>>luni at luni.org
>>http://luni.org/mailman/listinfo/luni
>>
>
More information about the luni
mailing list