1834885 Members
2884 Online
110071 Solutions
New Discussion

Re: uncompress default

 
Kurtkarl
Frequent Advisor

uncompress default

Hi,

We are running "uncompress ??? within a script. Once uncompress runs and if it finds existing file it prompts you whether to override it or not?

My question is, are there any parameters that we could use for uncompress not to prompt in case same file found and instead automatically "DONT" override existing files? or are there any scripts to use uncompress by defaulting the prompt to "N" if file exists?

THanks
Joey
Just starting to learn thru this forum
13 REPLIES 13
Rodney Hills
Honored Contributor

Re: uncompress default

Two choices-

1) remove the orginal file it is being uncompressed into first, before uncompress.

2) the "-f" option on uncompress will force it to overwrite the file.

-- Rod Hills
There be dragons...
Rodney Hills
Honored Contributor

Re: uncompress default

oops- I miss read your question.

Best thing to do is in the script do an "if" statement to test before uncompressing.

if [ ! -e yourfile ] ; then
uncompress yourfile.Z
fi

-- Rod Hills
There be dragons...
Justo Exposito
Esteemed Contributor

Re: uncompress default

Hi Joey,

You can check if the file exist first, somthing like that:

if [ -f filename ]
then
echo "the file allready exists then not overrider"
else
uncompress filename
fi

Hope this helps,

Justo.
Help is a Beatiful word
MANOJ SRIVASTAVA
Honored Contributor

Re: uncompress default

Hi Joey


use -f option .


ie uncompress -f it will not ask you to overwrite the file even if the same file exists.


All the best



Manoj Srivastava
Kurtkarl
Frequent Advisor

Re: uncompress default

Thanks for the reply, My other question is, what if
if we have to many files to test and we dont want to do several loops within the script just to test the file if existing or not?

Can we let uncompress program to do these test and just default it not to override existing files?

Thanks again
Joey
Just starting to learn thru this forum
Martin Johnson
Honored Contributor

Re: uncompress default

To answer your question, no, there are no parameters/qualifiers for uncompress that will give you the behavior you are looking for. You will have to use one of the scripting procedures already posted to your question. (They are valid solutions and deserve more than a "4".)


Marty
Rodney Hills
Honored Contributor

Re: uncompress default

To put it simply-

NO

The man page for uncompress gives no indication that this is available.

I assume you are doing something like a uncompress *.Z and only new files to be uncompressed. A shell script really would not be that ineffecient.

-- Rod Hills
There be dragons...
Justo Exposito
Esteemed Contributor

Re: uncompress default

Hi Again,

No there is not a parameter into uncompress.

See man page.

Regards,

Justo.
Help is a Beatiful word
Rodney Hills
Honored Contributor

Re: uncompress default

I did a test and an undocumented way is as follows-

uncompress *.Z &0

With STDERR set to null, uncompress can't do a prompt, so it defaults to no.

-- Rod Hills
There be dragons...
MANOJ SRIVASTAVA
Honored Contributor

Re: uncompress default

Joey


I think there is no option , the better way would be to move it to some toher direcotry and then uncompress it.


Manoj Srivastava
harry d brown jr
Honored Contributor

Re: uncompress default

Joey,

If you want multiple behaviors, then you are going to have to write a script to test if the file exists or not.

live free or die
harry
Live Free or Die
Rodney Hills
Honored Contributor

Re: uncompress default

You of course know that any suggestion given by these forums are not guaranteed and any damage to your system is not the responsibility of the provider of a solution.

I don't forsee any problems with my solution, but then again you are trying to do something a little "non-standard".

my 2 cents

-- Rod Hills
There be dragons...
Kurtkarl
Frequent Advisor

Re: uncompress default

Thanks for all of your replies. Really appreciate it. Rodney Hills reply works for us.. Thanks Rodney..

Again thanks
Joey
Just starting to learn thru this forum