LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-26-2005, 05:37 PM   #1
bokini
LQ Newbie
 
Registered: Oct 2003
Posts: 9

Rep: Reputation: 0
bash/tar


hello
Im doing a script and i have this line:
tar - Pcvz * --file file.tar.gz
OK! my question is that i wanna do this only if my curent directory has files in, otherwise do something else.
Thanks
 
Old 07-26-2005, 05:49 PM   #2
itsme86
Senior Member
 
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 59
You can check to see if ls | wc -l is 0.
 
Old 07-30-2005, 04:50 PM   #3
eddiebaby1023
Member
 
Registered: May 2005
Posts: 378

Rep: Reputation: 33
Code:
if test "./*" = ./*
then
    # directory empty
else
    # got at least one file (not named "*"  :-) )
fi
 
  


Reply



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
how can i decompress this tar.tar file? hmmm sounds new.. tar.tar.. help ;) kublador Linux - Software 14 10-25-2016 02:48 AM
Bash backup script failing using tar and --newer option saldkj Programming 3 03-12-2005 12:03 PM
Set name of tar file as date using bash otisthegbs Linux - Software 5 12-18-2003 03:34 PM
bash scripting and tar pengStudent Programming 2 11-17-2003 07:09 PM
Question about using bash and tar. amigatec Mandriva 3 10-04-2003 04:45 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:55 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
Open Source Consulting | Domain Registration