Results 1 to 6 of 6

Thread: How to test whether the files are existed or not

  1. #1
    Geek_Guest
    Guest

    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


  2. #2
    Junior Member
    Join Date
    Apr 2007
    Answers
    6

    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


  3. #3
    Junior Member
    Join Date
    Feb 2007
    Answers
    13

    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.


  4. #4
    Expert Member
    Join Date
    Dec 2006
    Answers
    204

    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.


  5. #5
    Junior Member
    Join Date
    Apr 2007
    Answers
    6

    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



  6. #6
    Contributing Member
    Join Date
    Apr 2007
    Answers
    41

    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


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact