Sponsored Content
Top Forums Shell Programming and Scripting How to check if a file exists in a directory? Post 302588174 by ahamed101 on Saturday 7th of January 2012 09:02:11 AM
Old 01-07-2012
Code:
if [ ! -f /home/loc/etc/load.txt ]
then
  echo "File does not exist. Exiting..."
  exit 1
fi

this may help

--ahamed
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

check if directory exists

Hi, I need to prompt for a response from a user to enter a path read dest_dir?"Please Enter Directory :" How do I do this until a valid directory is entered by the user. I can use to check the existence of the directory. However when I try the following I cannot get it to work. while ... (2 Replies)
Discussion started by: jerardfjay
2 Replies

2. Shell Programming and Scripting

how to check if masked directory exists?

I'm trying to write a script that identifies whether a directory of the form AWL.????????.IP exists. I have one that exists which is AWL.05301032.IP. When I test like this: If ] I get true, but when I test like this: If ] Or like this If ] Or any other variation of wild cards, I... (4 Replies)
Discussion started by: philplasma
4 Replies

3. UNIX for Dummies Questions & Answers

How can I check if directory exists in a makefile

Hi. I what to write a make file that inside a target I want to check if a directory exists. some like: ### make a: if ;then <command 1> else <command 2> fi ### make end Thanks a lot ---------------------- (2 Replies)
Discussion started by: zivsegal
2 Replies

4. Shell Programming and Scripting

my scripts does not check if directory exists

Hello: Can someone please help me figure out what is wrong here, my script does not move on to the "else" part even though there is no .ssh directory on my remote server: $more putkey.sh #!/bin/ksh for server in `cat list` do if ; then cat $HOME/.ssh/id_rsa.pub |ssh $server ' cat >>... (4 Replies)
Discussion started by: Sara-sh
4 Replies

5. Shell Programming and Scripting

check if a directory exists if not make it

Hey guys im trying to check if the directory exists i get a syntax error on the elif statement iv tried using else and still same result im not sure. If the directory does not exist can i just insert mkdir /tmp/old under the elif once that part gets working if ; then #do nothing elif echo... (20 Replies)
Discussion started by: musicmancanora
20 Replies

6. Shell Programming and Scripting

check if directory and file exists

cp $PATHLOGS/$DATE/*.* $TMP/logs_tmp/ cp $PATHLOGS/$DATE1/*.* $TMP/logs_tmp/ Before copying the files I have to check if the directory $DATE1 and $DATE2 exists. If directory exists then, check if the folder contains some files. if the file exists then, check if the file size is greater... (3 Replies)
Discussion started by: sandy1028
3 Replies

7. Shell Programming and Scripting

how to check if a directory exists or not.if not need to create it

Hi, I am using solaris 10 OS and bash shell.just checking for small code snippet which follows below. /export/home/vomappservers/spa/common/5.0 /export/home/vomappservers/spa/common/scripts /export/home/vomappservers/spa/tools /export/home/vomappservers/spa/scm5.0/SCCS... (5 Replies)
Discussion started by: muraliinfy04
5 Replies

8. Shell Programming and Scripting

How to check if the file exists in directory?

Hi Gurus, I have a requests to find if all the file in the filelist exist in certain directory. example: my filelist abc def ddd cde afg how can I find these 5 files exists at director /home/abc Thanks in advance (7 Replies)
Discussion started by: ken6503
7 Replies

9. Shell Programming and Scripting

Check whether file exists in directory

Hi guys, I am beginner trying to learn unix. So any help is welcomed. My requirement is to check whether is a file exists in a particular directory or not. The directory path and filename are taken dynamically with user interaction. So the program should continue only if the $filename... (1 Reply)
Discussion started by: maris_markur
1 Replies

10. UNIX for Beginners Questions & Answers

Check that at least one file exists in the directory.

There are some files with suffix dates like abc_20032019.dat abc_17032019.dat If at least one file exists then perform some operation else exit from execution. Korn shell ---------------------------------- array=($inputdir/abc*.dat) If ] ] then echo " file exits" else echo " file does... (10 Replies)
Discussion started by: Rajesh123
10 Replies
cowbuilder(8)							     cowdancer							     cowbuilder(8)

NAME
cowbuilder - a pbuilder wrapper for cowdancer. SYNOPSIS
cowbuilder [commands] [options] DESCRIPTION
cowbuilder Executes the specified pbuilder operation with cowdancer COMMANDS
Most commands invoke pbuilder with the specified commands, see pbuilder manual for details. --create Create the base.cow image. The directory for base.cow should be empty, or this command will fail. --update Update the base.cow image. --build .dsc-file Build a package given a .dsc file --login Start a session within the base.cow. --execute Execute a command within the base.cow. --dumpconfig dump configuration information. OPTIONS
Most options are the same as pbuilder, except for the following which are handled specially --buildplace The place where COW operation takes place. --basepath has a very different meaning to basetgz option of pbuilder, since there is no tgz. This option specifies the directory in which the COW master data is stored, the default being /var/cache/pbuilder/base.cow --configfile [configuration file to load] Additional configuration file to read after all other configuration files have been read. --no-cowdancer-update Do not use cowdancer on cowbuilder --update. Please use this option when cowdancer is interfering with upgrade process, or cowdancer itself is being upgraded within chroot. --debian-etch-workaround Work around on Debian etch compatibility. cow-shell will search for all files in chroot, but will work. CONFIGURATION FILES
cowbuilder reads the following configuration files per default. /usr/share/pbuilder/pbuilderrc Application default, not to be changed. /etc/pbuilderrc System-wide default. ~/.pbuilderrc User default anything specified with --configfile option Additional configuration at runtime. CONFIGURATION FILE OPTIONS
The possible configuration options are as follows. Others are ignored. DISTRIBUTION=distribution BUILDRESULT=directory BUILDPLACE=directory BASEPATH=path MIRRORSITE=http://mirror NO_COWDANCER_UPDATE=1 See --no-cowdancer-update DEBIAN_ETCH_WORKAROUND=1 See --debian-etch-workaround EXAMPLES
cowbuilder --create Create a base.cow image. # cowbuilder --create --hookdir /usr/share/doc/pbuilder/examples/workaround/ --distribution etch --debootstrap debootstrap --basepath /var/cache/pbuilder/base-test.cow bash: /root/.pbuilderrc: No such file or directory W: /home/dancer/.pbuilderrc does not exist -> Running in no-targz mode Distribution is etch. Building the build environment -> running debootstrap /usr/sbin/debootstrap I: Retrieving Release . . cowbuilder --update Update the base.cow image. # cowbuilder --update bash: /root/.pbuilderrc: No such file or directory -> Copying COW directory -> Invoking pbuilder W: /home/dancer/.pbuilderrc does not exist -> Running in no-targz mode -> copying local configuration -> mounting /proc filesystem -> mounting /dev/pts filesystem -> policy-rc.d already exists Refreshing the base.tgz -> upgrading packages . . cowbuilder --build test_0.1.dsc Build the package specified in dsc file, with the base.cow image. pdebuild --pbuilder cowbuilder Run cowbuilder --build against the current directory. The current directory should be an extracted Debian source package directory. Edit /etc/pbuilderrc to have PDEBUILD_PBUILDER=cowbuilder to make this the default behavior for pdebuild. cowbuilder --login --bindmounts /home/dancer Start a cow-shell session inside base.cow, with /home/dancer being bind-mounted to within chroot. Note that cowbuilder will not cow-protect what is inside /home/ # cowbuilder --login --bindmount ${HOME} bash: /root/.pbuilderrc: No such file or directory -> Copying COW directory -> Invoking pbuilder W: /home/dancer/.pbuilderrc does not exist -> Running in no-targz mode -> copying local configuration -> mounting /proc filesystem -> mounting /dev/pts filesystem -> Mounting /home/dancer -> policy-rc.d already exists -> entering the shell # cowbuilder --create --distribution sid --basepath /var/cache/pbuilder/base-test.cow Create a base.cow image with the path /var/cache/pbuilder/base-test.cow and distribution sid. AUTHOR
Junichi Uekawa (dancer@debian.org) SEE ALSO
/usr/share/doc/pbuilder/pbuilder-doc.html, pbuilder (8), pdebuild (1) cowdancer 2007 Jun 17 cowbuilder(8)
All times are GMT -4. The time now is 04:10 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy