Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

tar asking if I want to overwrite

Status
Not open for further replies.

Chrissirhc

Programmer
May 20, 2000
926
GB
Hi in my script when I run tar cf $archiveXMLs *.xml

where $archiveXMLs is myChosenNameOfTar.tar, if myChosenNameOfTar.tar already exists the script asks me if I want to overwrite it. I always want to overwrite it, so what switch should I use to make it not ask me??

Thanks,

Chris
 
You could add a line to do a rm -f or cp the file using a new name prior to you starting to write the file again.
 
Thanks Comtec,

That's an option. Would you know if there is a way to force a yes though with tar command?? I have a few tar commands in the script. Also that would also just be nice to know.

Thanks,

Chris
 
Anyway, what about
Code:
 man tar
?

Hope This Help
PH.
 
I had looked up tar on the computerhope unix manual pages and didn't find anything. Would you know off-hand?
 
Hi,

Is there a switch to just make the tar command force overwrite existing files?

I could test for the existance of the file first and delete it or try Annihilannics example if neccessary.

However I'd ilke to know for accademic reasons.

Thanks,

Chris
 
Not that I know of, I've never seen tar complain about overwriting an existing file before.

What operating system is it?

Annihilannic.
 
are you testing the script by running each command from a command line? If you run a true script, it should not complain.
 
Its Sun Solaris.

I'm running it from a script. I need to also test from a crontab.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top