Want to create 3 different new directories under the same path


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Want to create 3 different new directories under the same path
# 1  
Old 11-21-2008
Want to create 3 different new directories under the same path

Hi,
Iam new to UNIX...My requirement is to create 3 dir as an hierarchy under /var/opt/temip.The output should be /var/opt/temip/GP_Int/GPTTS/AUTO.
I have tried the following script...But only GP_int folder is getting created and not other folders...Can someone help???
#!/usr/bin/ksh
#script to create directory structure.
filename=/var/opt/temip
echo $filename
dirname=GP_Integration
echo $dirname

if [ -d $dirname ]
then
echo "directory exists already"
else
mkdir -p $(dirname $filename)
echo "directory GP_Integration created"

filename=/var/opt/temip/GP_Integration
echo $filename
dirname=GPTTS
echo $dirname
if [ -d $dirname ]
then
echo "directory exists already"
else
mkdir -p $(dirname $filename)
echo "directory GPTTS created"
fi

fi
Thanks...
# 2  
Old 11-21-2008
First of all, just "mkdir -p /var/opt/temip/GP_Int/GPTTS/AUTO" should work. The -p switch will suppress errors if the dirs exist and create the parents.

Reply if you need more help. You confused me a bit with "filename" and "dirname" by using a directory as filename...
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. HP-UX

Adding Directories to PATH in HP-UX with csh

HI Guys, I am truing to add some directories to the productive HP-UX (like /usr/sbin) the problem is that i tried some methods like (export) and setenv but i failed. I add some logs output of the commands to provide you with more info . the user which I am trying to add this path is different... (5 Replies)
Discussion started by: barry1946
5 Replies

2. Shell Programming and Scripting

Function to remove the directories from PATH variable

Hello, From the URL https://www.unix.com/shell-programming-scripting/121303-remove-path-path-environment-variable-2.html I got a function to remove the directories from a path. but looks like this isnt quite working.. i am also not able to post the comments in the thread as it is closed. ... (6 Replies)
Discussion started by: satishkumar432
6 Replies

3. Shell Programming and Scripting

Print path files in different directories

Hi guys :) First of all Happy New Year :) so i dont know if my doubt its already here posted by other person ... i need to print to one file the path of few files that are in different directories, like this: directory muscle ATP6.aa.muscle.fasta COX1.aa.muscle.fasta . . . ... (2 Replies)
Discussion started by: andreia
2 Replies

4. Shell Programming and Scripting

How to list all the files, directories and sub-directories in the current path except one directory?

Can anyone come up with a unix command that lists all the files, directories and sub-directories in the current directory except a folder called log.? Thank you in advance. (7 Replies)
Discussion started by: Manjunath B
7 Replies

5. UNIX for Dummies Questions & Answers

Highlight directories in path with execute permission for others

Hi all, I'm trying to make a script that takes at the most one argument and lists all directories in the path in a special format: User Group Other Filename rwx r-- r-x \ rwx r-x r-- home This is my code as it is... (1 Reply)
Discussion started by: Trinimini
1 Replies

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

7. Shell Programming and Scripting

find in given path do not want to traverse to its sub-directories

Hi All, My UNIX Version is: OS Name Release Version AIX appma538 3 5 I want to find certain files with some criterias under the given path. At the same time i want to find the files which resides under the given directory, but normal find traverse to its sub-directories... (4 Replies)
Discussion started by: Arunprasad
4 Replies

8. Shell Programming and Scripting

How to check if all directories of file's path exists?

I wonder if the script below is possible to write somehow more efficiently. It seems to me the problem is very common.. CreateFolders() # parameter: name of file with relative path with regard to directory $project_root { echo $1 | awk '{ n=split($1, array, "/"); ... (2 Replies)
Discussion started by: MartyIX
2 Replies

9. Shell Programming and Scripting

Find a file in sub-directories.. o/p just the path

Hello All, I am somehow stumped with this ting. 'Find' will sure show me.. but I want only thepath of all the occurences of the file in any of the sub-dirs.. Any help will be sincerely appreciated. thanx! (3 Replies)
Discussion started by: pranavagarwal
3 Replies

10. Shell Programming and Scripting

Bash Script to display directories in Path?

Hello there, As a newbie: The directories in PATH can be hard to distinguish when printed out as one line with colon .Please, can i have a sample script to display them,one to a line. Thank you. (1 Reply)
Discussion started by: debut
1 Replies
Login or Register to Ask a Question