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


Reply
  Search this Thread
Old 02-11-2004, 11:53 AM   #1
webamoeba
LQ Newbie
 
Registered: Nov 2003
Posts: 18

Rep: Reputation: 0
bash script - even more stupid question than last time.




tar -xf somefile.tar

if it is successfull returns 0
Code:
if [ tar -xf somefile.tar ]
    then
        echo fail
    else
        echo success
    fi
this makes sense to me! if it is successfull e.g 0 if will be false and echos success. Thing is, it doesn't complete tar -xf somefile.tar

How do I do this????

Thanks

Last edited by webamoeba; 02-11-2004 at 11:58 AM.
 
Old 02-11-2004, 12:35 PM   #2
ugenn
Member
 
Registered: Apr 2002
Posts: 549

Rep: Reputation: 30
tar -xf somefile.tar
if [ $? == 0 ] ; then
echo fail
else
echo success
fi
 
Old 02-12-2004, 04:03 AM   #3
webamoeba
LQ Newbie
 
Registered: Nov 2003
Posts: 18

Original Poster
Rep: Reputation: 0
Thanks ($? must remember that)

actually had to use -eq as was binary.
 
  


Reply


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
Get file modification date/time in Bash script cmfarley19 Programming 16 04-15-2015 07:25 PM
stupid bash question tisleti Linux - Newbie 4 09-10-2004 06:34 AM
bash script question djgerbavore Linux - Newbie 3 07-08-2004 04:39 PM
OK stupid question time....Mozilla mannymann Linux - Newbie 6 05-10-2004 10:21 PM
bash script question xscousr Programming 5 07-03-2003 06:04 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:11 AM.

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