Sponsored Content
Top Forums Shell Programming and Scripting how to check if directory/file exist using c/c++ Post 94635 by Perderabo on Monday 2nd of January 2006 09:45:32 PM
Old 01-02-2006
Please make sure that you have read our rules. And note:
(4) Do not 'bump up' questions if they are not answered promptly. No duplicate or cross-posting and do not report a post where your goal is to get an answer more quickly.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

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 (3 Replies)
Discussion started by: gusla
3 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 if certain files exist in a directory, if not add name to a textfile

We recieve some logs on our windows box via FTP on a daily basis, in the same directory. I would like to check for missing logs files and add their name to a text file. Something like... Check if C:\logs\file1_currentdate exists (if not, add file1_currentdate to... (1 Reply)
Discussion started by: SunnyK
1 Replies

4. Shell Programming and Scripting

How to check directory exist on servers

There are many servers and their directory structer should be exactly the same. To check the directory path for all servers, I wrote a script. #! /bin/ksh ARRAY_DIRECTORIES="/c/dev/custom/bin" ARRAY_DIRECTORIES="/c/dev/db/custom/src" ARRAY_ENV="remoteName200" ARRAY_ENV="remoteName201"... (2 Replies)
Discussion started by: weonpc
2 Replies

5. Shell Programming and Scripting

To check whether a directory is exist and if it is not, create it

Hi, I want to write a shell script to check whether a directory (say A) is existing in a given location and if it is not, create it. (3 Replies)
Discussion started by: sabya
3 Replies

6. Shell Programming and Scripting

check the directory exist

I have the below script to check whether directory is exist or not , now I sure the directory /abc NOT exist , but when run the script , it still pop the result is "the directory exist" , could suggest what is wrong ? thx ll -d /abc > /dev/null 2>&1 if then echo "the directory exist !!" ... (7 Replies)
Discussion started by: ust
7 Replies

7. 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

8. 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

9. 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

10. 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
FLOCK(1)							   User Commands							  FLOCK(1)

NAME
flock - manage locks from shell scripts SYNOPSIS
flock [-sxon] [-w timeout] lockfile [-c] command... flock [-sxon] [-w timeout] lockdir [-c] command... flock [-sxun] [-w timeout] fd DESCRIPTION
This utility manages flock(2) locks from within shell scripts or the command line. The first and second forms wraps the lock around the executing a command, in a manner similar to su(1) or newgrp(1). It locks a specified file or directory, which is created (assuming appropriate permissions), if it does not already exist. The third form is convenient inside shell scripts, and is usually used the following manner: ( flock -n 9 || exit 1 # ... commands executed under lock ... ) 9>/var/lock/mylockfile The mode used to open the file doesn't matter to flock; using > or >> allows the lockfile to be created if it does not already exist, how- ever, write permission is required; using < requires that the file already exists but only read permission is required. By default, if the lock cannot be immediately acquired, flock waits until the lock is available. OPTIONS
-s, --shared Obtain a shared lock, sometimes called a read lock. -x, -e, --exclusive Obtain an exclusive lock, sometimes called a write lock. This is the default. -u, --unlock Drop a lock. This is usually not required, since a lock is automatically dropped when the file is closed. However, it may be required in special cases, for example if the enclosed command group may have forked a background process which should not be hold- ing the lock. -n, --nb, --nonblock Fail (with an exit code of 1) rather than wait if the lock cannot be immediately acquired. -w, --wait, --timeout seconds Fail (with an exit code of 1) if the lock cannot be acquired within seconds seconds. Decimal fractional values are allowed. -o, --close Close the file descriptor on which the lock is held before executing command. This is useful if command spawns a child process which should not be holding the lock. -c, --command command Pass a single command to the shell with -c. -h, --help Print a help message. AUTHOR
Written by H. Peter Anvin <hpa@zytor.com>. COPYRIGHT
Copyright (C) 2003-2006 H. Peter Anvin. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICU- LAR PURPOSE. SEE ALSO
flock(2) AVAILABILITY
The flock command is part of the util-linux package and is available from ftp://ftp.kernel.org/pub/linux/utils/util-linux/. util-linux February 2006 FLOCK(1)
All times are GMT -4. The time now is 08:30 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy