Sponsored Content
Top Forums Shell Programming and Scripting To check whether a directory is exist and if it is not, create it Post 302238525 by yahyaaa on Saturday 20th of September 2008 01:13:27 PM
Old 09-20-2008
try to grep it... if it's not existed, the grep will return null.. if this is true make the directory..


#! /bin/ksh

var=$( ls -1 \Yourpath | grep "A" )

if [[ "$var" -eq " " ]] ; then

mkdir A

done
 

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

If file not exist create a new one

i want a script to check whether the file name exits or not if not it has to create a new one (3 Replies)
Discussion started by: din_annauniv
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 multiple directories exist else create missing directories

Hi , I 'm trying to check if multiple directories exist on a server, if not create the missing ones and print " creating missing directory. how to write this in a simple script, I have made my code complex if ; then taskStatus="Schema extract directory exists, checking if SQL,Count and... (7 Replies)
Discussion started by: ramky79
7 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

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

10. Shell Programming and Scripting

Bash to check directory and create missing folder from file

In the below bash I am trying to ensure that all folders (represented by $folders) in a given directory are created. In the file f1 the trimmed folder will be there somewhere (will be multiple trimmed folders). When that trimmed folder is found (represented by $S5) the the contents of $2 printed... (19 Replies)
Discussion started by: cmccabe
19 Replies
luseradd(8)						      System Manager's Manual						       luseradd(8)

NAME
luseradd - Add an user SYNOPSIS
luseradd [OPTION]... user DESCRIPTION
Adds an user with name user. OPTIONS
-c, --gecos=gecos Set the GECOS field to gecos. The GECOS field is traditionally used to store user's real name and other information. -d, --directory=directory Set user's home directory to directory. If this option is not present, a default specified by libuser configuration is used. -g, --gid=group Set user's primary group to group. group can either be a group ID of an existing group, or a group name; if group is a group name and the group does not exist, it is created. If the --gid option is not specified, the default group name is user. -i, --interactive Ask all questions when connecting to the user database, even if default answers are set up in libuser configuration. -k, --skeleton=directory Populate the newly created user's home directory with a copy of directory. If this option is not present, a default directory spec- ified by libuser configuration, or /etc/skel if libuser configuration does not specify a default, is used. -M, --nocreatehome Don't create a home directory and a mail spool for the newly created user. -n, --nocreategroup If a group is not specified using -g, use group name "users" instead of user. Note that despite the name of the option, the group will still be created if it does not exist. -P, --plainpassword=password Set user's password to password. Note that the password can be viewed while running luseradd using tools such as ps(1). -p, --password=encrypted Set user's password to the password represented by the hash encrypted. Note that the hash can be viewed while running luseradd using tools such as ps(1). -r, --reserved The user is a system user. Users that are not marked as system user usually have automatically selected user IDs above a certain value (500 by default). This information is also passed to the libuser backends. This option implies the -M option. -s, --shell=shell Set user's login shell to shell. If this option is not present, a default specified by libuser configuration is used. -u, --uid=uid Use user ID uid for the newly created user. An user ID is selected automatically if this option is not present. EXIT STATUS
The exit status is 0 on success, nonzero on error. libuser Jan 12 2005 luseradd(8)
All times are GMT -4. The time now is 08:41 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy