Geeks Talk

Prepare for your Next Interview




How to test whether the files are existed or not

This is a discussion on How to test whether the files are existed or not within the Unix/Linux forums, part of the Operating Systems category; How to test whether the files are existed or not in particular folder from required list. If any file missed need to send mail with list of files missed and ...


Go Back   Geeks Talk > Operating Systems > Unix/Linux

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 05-13-2007
Expert Member
 
Join Date: Feb 2007
Posts: 1,279
Thanks: 0
Thanked 164 Times in 138 Posts
Geek_Guest is on a distinguished roadGeek_Guest is on a distinguished road
How to test whether the files are existed or not

How to test whether the files are existed or not in particular folder from required list. If any file missed need to send mail with list of files missed and suspend the process some time

Thanks in advance
Suresh

Question asked by visitor suresh
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 05-15-2007
Junior Member
 
Join Date: Apr 2007
Location: Balgalore
Posts: 5
Thanks: 0
Thanked 1 Time in 1 Post
md.jahidanwar is on a distinguished road
Re: How to test whether the files are existed or not

Hi Suresh ,
Whenever we will create a file using Cat Coommand,or ed command,or Vi file name...............
We check whether it is create successfully or not using the command
echo $?
if returns 0 then it create successfully
if returns non zero value not create .....
Regards
Jahid
Reply With Quote
  #3 (permalink)  
Old 05-15-2007
Junior Member
 
Join Date: Feb 2007
Posts: 15
Thanks: 2
Thanked 1 Time in 1 Post
rpgubba is on a distinguished road
Re: How to test whether the files are existed or not

The filename is written in place of "?".
echo $?

Can you please give us some example.
Reply With Quote
  #4 (permalink)  
Old 05-15-2007
Expert Member
 
Join Date: Dec 2006
Location: Chennai
Posts: 197
Thanks: 2
Thanked 16 Times in 14 Posts
Barbie is on a distinguished road
Re: How to test whether the files are existed or not

-s will checks for the presence of the file.

if [ -s $file ]; then
#file found
else
#file not found
fi

The variable $file should have the file name with location as /user/barbie/sample.txt.
Reply With Quote
  #5 (permalink)  
Old 05-16-2007
Junior Member
 
Join Date: Apr 2007
Location: Balgalore
Posts: 5
Thanks: 0
Thanked 1 Time in 1 Post
md.jahidanwar is on a distinguished road
Re: How to test whether the files are existed or not

Dear Rpgubba,
Q. As u told echo $? ,If u want to write a filename instead of "?"

That means u write like echo $filename

It is not an error but it is take as a variable not a take filename.

For instance
echo $filename hello how ru
the o/p is hello how ru
Reply With Quote
The Following User Says Thank You to md.jahidanwar For This Useful Post:
  #6 (permalink)  
Old 05-28-2007
Contributing Member
 
Join Date: Apr 2007
Location: Bangalore
Posts: 44
Thanks: 6
Thanked 7 Times in 6 Posts
prakash.kudrekar is on a distinguished road
Re: How to test whether the files are existed or not

I thnk the command goes like this

#echo $filename
where filename is the one which u want to search for???

regards
Prakash
Reply With Quote
Reply

  Geeks Talk > Operating Systems > Unix/Linux


Thread Tools
Display Modes


Similar Threads

Thread Thread Starter Forum Replies Last Post
If test case required for testing always post test scenario. jainbrijesh Test Cases 12 09-09-2008 11:36 PM
Uploading Test Cases into Quality Center and Test Director Rajani Test Director 2 05-13-2008 05:27 AM
Running Test in Test Director Test Lab without QTP Geek_Guest QTP 2 12-24-2007 01:57 AM
If no rows existed in target then error will come Geek_Guest Data Warehousing 0 04-03-2007 11:20 AM
How toTake Backup of all files from Test director 7.2 swamy.an Test Director 1 03-01-2007 05:55 AM


All times are GMT -4. The time now is 01:25 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Copyright © 2008 GeekInterview.com. All Rights Reserved