LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Closed Thread
  Search this Thread
Old 03-22-2004, 01:14 AM   #1
VisionZ
Member
 
Registered: Mar 2004
Posts: 58

Rep: Reputation: 15
Helpwriting a script that tar's multiple scripts in all folders but not itself


Basically I need help TARRing everyscript I have written in all my different folders under and including my home folder, BUT which wont TAR itself. A bonus would be if it checks to see if the tar archive it is creating also exists and then if it does it makes it but just adds a 1 or 2 and them so on up. Any help would be greatly appreciated as I am new to shell scripting. FYI I,m using the BASH shell.
 
Old 03-22-2004, 01:28 AM   #2
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 96
Hi.

To check if a file exists:

if [ -f <file> ]; then
do stuff
fi

Also, $0 will contain the name used to launch the script (usually the name of the script, but not always), so you could use that to remove the script from the list of files to be tarred.

Hope that gets some way.

Dave.
 
Old 03-22-2004, 04:49 AM   #3
XavierP
Moderator
 
Registered: Nov 2002
Location: Kent, England
Distribution: Debian Testing
Posts: 19,192
Blog Entries: 4

Rep: Reputation: 469Reputation: 469Reputation: 469Reputation: 469Reputation: 469
Please do not post the same thread in more than one forum. Picking the most relevant forum and posting it once there makes it easier for other members to help you and keeps the discussion all in one place.

http://www.linuxquestions.org/rules.php

The original is here: http://www.linuxquestions.org/questi...hreadid=159583
 
  


Closed Thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
tar's problem happy78 Linux - General 5 11-03-2005 01:17 PM
TH8/Sendmail Question: Multiple folders ertzsi Red Hat 3 10-22-2005 07:40 PM
Changing file permissions within multiple folders cloudxiii Linux - Newbie 1 02-21-2005 01:20 AM
A script to make folders... MadClouds Linux - Newbie 2 11-26-2003 09:39 PM
Giant tar's pk21 Linux - General 4 09-04-2003 02:37 PM


All times are GMT -5. The time now is 10:36 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration