Sponsored Content
Top Forums UNIX for Dummies Questions & Answers how to check if the file exist or not? Post 18316 by gusla on Wednesday 27th of March 2002 01:55:25 AM
Old 03-27-2002
Data how to check if the file exist or not?

say i would like to check if the file is existed before i use rm command. How can i do it?

i know if i can use find, but i would like to have a good interface (in a shell script)



thks
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to check if directory/file exist using c/c++

Hi there,, how to check if directory/file exist using c/c++ under unix/linux? I can use access() under Window MFC. Thanks. Steven (1 Reply)
Discussion started by: steven88
1 Replies

2. Programming

how to check if directory/file exist using c/c++

Hi there, how to check if directory/file exist using c/c++ under linux/unix. Thanks. Steven (2 Replies)
Discussion started by: steven88
2 Replies

3. Shell Programming and Scripting

Check Word if exist on file or not

Hello, I want to check if some word exist or not on some file By Example : word is : nixcraft file called : /root/shell.txt and i want to check if nixcraft word exist on /root/shell.txt file with if statement or another tool Any Ideas (5 Replies)
Discussion started by: LinuxCommandos
5 Replies

4. Shell Programming and Scripting

Check if file exist

Hi Does anybody know how I can check if a file exists i.e. see bellow, this doesn't work by the way and if tried countless variations on this file1=$one/file111.txt if then echo "Present" else echo "Not present" fi result : Not present (file is already present, eventhough its... (3 Replies)
Discussion started by: gksenthilkumar
3 Replies

5. Shell Programming and Scripting

Check file exist issue

I have created two scripts, one with hardcoded and another one with extract from file instead of hardcoded, script:1 -------- #!/bin/ksh filename="$one/file1.dat" if then echo "$filename has arrived." >> $logfile else echo "$filename has NOT yet arrived." >> $logfile fi :> Result:... (4 Replies)
Discussion started by: gksenthilkumar
4 Replies

6. Shell Programming and Scripting

Check if file exist

Hi, I am trying to create a bash script which will check if file exist then remove that file else do nothing. I have to do same process for three files in same script. I have written code for one file and trying to run it. if then rm -r /user1/abc/File1 fi When I run this code it... (1 Reply)
Discussion started by: palak08
1 Replies

7. Shell Programming and Scripting

Check if file exist

Hi, I created following script to check if file exist: #!/bin/bash SrcDir=$1 SrcFileName=$2 SrcTimePeriod=$3 if ;then echo 1 else echo 0 fi I ran it like: /apps/Scripts/FileExist.sh /apps/Inbox file1 2nd_period_2010 Even file exist at that location, my above command is... (4 Replies)
Discussion started by: palak08
4 Replies

8. Shell Programming and Scripting

how to check file exist in a directory or not

HI folks, can any one tell me how to check whether the file is existed in a directory or not . let me tell you my requirement : if the file is existed i should display a one message or else i have to send a mail .. i have the mail logic .. but I'm failed to check file existence .. please... (5 Replies)
Discussion started by: sravan008
5 Replies

9. Shell Programming and Scripting

check file exist before execution

Hi , I have a scripts which run at every 1 min and do some job. this scripts look for the file in the directory and move in the other directory. I want to write a line which forst check if the *.LOG file exist in the directory if *.LOG exist then do for i in *.LOG load ... (7 Replies)
Discussion started by: guddu_12
7 Replies

10. Shell Programming and Scripting

Check for a file and touch if not exist

Hi, I've a situation where i need to check for the file existence and create a zero byte file based on the parameter,in some cases i need to touch and in some case i dont need to touch with zero byte file please help me on parameterizing this touch command?? Regards. San (2 Replies)
Discussion started by: sandeep karna
2 Replies
Padre::Document::Perl::Beginner(3pm)			User Contributed Perl Documentation		      Padre::Document::Perl::Beginner(3pm)

NAME
Padre::Document::Perl::Beginner - naive implementation of some beginner specific error checking SYNOPSIS
use Padre::Document::Perl::Beginner; my $beginner = Padre::Document::Perl::Beginner->new; if (not $beginner->check($data)) { warn $beginner->error; } DESCRIPTION
This is a naive implementation. It needs to be replaced by one using PPI. In Perl 5 there are lots of pitfalls the unaware, especially the beginner can easily fall in. While some might expect the Perl compiler itself would catch those it does not (yet ?) do it. So we took the initiative and added a beginners mode to Padre in which these extra issues are checked. Some are real problems that would trigger an error anyway we just make them a special case with a more specific error message. (e.g. "use warning;" without the trailing s) Others are valid code that can be useful in the hands of a master but that are poisonous when written by mistake by someone who does not understand them. (e.g. "if ($x = /value/) { }" ). This module provides a method called "check" that can check a Perl script (provided as parameter as a single string) and recognize problematic code. Examples See <http://padre.perlide.org/ticket/52> and <http://www.perlmonks.org/?node_id=728569> Cases o split /,/, @data; Here @data is in scalar context returning the number of elements. Spotted in this form: split /,/, @ARGV; o use warning; s is missing at the end. o map { $_; } (@items),$extra_item; is the same as map { $_; } (@items,$extra_item); but you usually want (map { $_; } (@items)),$extra_item; which means: map all @items and them add $extra_item without mapping it. o Warn about Perl-standard package names being reused package DB; o $x = chomp $y; print chomp $y; o map { s/foo/bar/; } (@items); This returns an array containing true or false values (s/// - return value). Use map { s/foo/bar/; $_; } (@items); to actually change the array via s///. o <@X> o if ($x = /bla/) { } o Pipe | in open() not at the end or the beginning. o open($ph, "| something |"); o Regular expression starting with a quantifier such as /+.../ o } else if { o } elseif { o close; HOW TO ADD ANOTHER ONE
Please feel free to add as many checks as you like. This is done in three steps: Add the test Add one (or more) tests for this case to t/75-perl-beginner.t The test should be successful when your supplied sample fails the check and returns the correct error message. As texts of error messages may change, try to match a good part which allows identification of the message but don't match the very exact text. Tests could use either one-liners written as strings within the test file or external support files. There are samples for both ways in the test script. Add the check Add the check to the check-sub of this file (Document/Perl/Beginner.pm). There are plenty samples here. Remember to add a sample (and maybe short description) what would fail the test. Run the test script to match your test case(s) to the new check. Add the configuration option Go to Config.pm, look for the beginner error checks configuration and add a new setting for your new check there. It defaults to 1 (run the check), but a user could turn it off by setting this to 0 within the Padre configuration file. COPYRIGHT &; LICENSE Copyright 2008-2012 The Padre development team as listed in Padre.pm. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. perl v5.14.2 2012-06-27 Padre::Document::Perl::Beginner(3pm)
All times are GMT -4. The time now is 06:19 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy