LinuxQuestions.org
Register a domain and help support LQ
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 04-08-2012, 06:58 AM   #1
xombboxer
Member
 
Registered: Apr 2011
Posts: 63

Rep: Reputation: 0
Check whether a .zip exist or not


I am trying to check whether the file classes.zip is present or not using below line.
it seems its not able to check it. it says file does not exist, even though the file is present

Code:
if [ ! -f ${cacheFloc}/classes.zip ]
any help ?
 
Old 04-08-2012, 11:43 AM   #2
engr04
LQ Newbie
 
Registered: Mar 2012
Posts: 21

Rep: Reputation: Disabled
Code:
if [ ! -f ${cacheFloc}/classes.zip ]
Is true if the file is not found

Code:
if [ ! -f ${cacheFloc}/classes.zip ]
Is true if the file is found

Example:

Code:
FILENAME=classes.zip

if [ -f $FILENAME ]; then
	echo $FILENAME found
else
	echo $FILENAME missing
fi
I have an embedded board where the '-f' option is not available. Here's an alternate way:

Code:
FILENAME=classes.zip

if [ `ls $FILENAME` ]; then
	echo $FILENAME found
else
	echo $FILENAME missing
fi
 
Old 04-08-2012, 11:57 AM   #3
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,252

Rep: Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685
Are you sure 'cacheFloc' has the correct value in it?
 
Old 04-08-2012, 01:17 PM   #4
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,063

Rep: Reputation: 381Reputation: 381Reputation: 381Reputation: 381
There's nothing wrong in that line but it depends in the context. As someone said you should check the contents of that var. Also, if you couldn't use -f I'd rather use 'stat' than 'ls'.
 
  


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
Check if directory DOES NOT exist in BASH Drigo Linux - Newbie 12 05-03-2012 07:35 AM
how to check directory exist or not nagendrar Solaris / OpenSolaris 1 04-30-2010 03:06 AM
check if directory exist jaepi Programming 6 05-10-2007 09:45 PM
Check if email exist or not proNick Linux - Software 2 08-27-2005 02:25 PM
How to check if a software exist in my computer Niceman2005 Linux - Newbie 4 12-28-2004 10:12 PM


All times are GMT -5. The time now is 05:07 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