Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


Closed Thread
  Search this Thread
Old 03-22-2004, 12:14 AM   #1
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, 12:28 AM   #2
Senior Member
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 96

To check if a file exists:

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

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.

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

Rep: Reputation: 475Reputation: 475Reputation: 475Reputation: 475Reputation: 475
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.

The original is here:

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 12:17 PM
TH8/Sendmail Question: Multiple folders ertzsi Red Hat 3 10-22-2005 06:40 PM
Changing file permissions within multiple folders cloudxiii Linux - Newbie 1 02-21-2005 12:20 AM
A script to make folders... MadClouds Linux - Newbie 2 11-26-2003 08:39 PM
Giant tar's pk21 Linux - General 4 09-04-2003 01:37 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:56 PM.

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