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...
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
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
2. Shell Programming and Scripting
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
3. Shell Programming and Scripting
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
4. Shell Programming and Scripting
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
5. Shell Programming and Scripting
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
6. UNIX for Dummies Questions & Answers
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
7. Shell Programming and Scripting
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
8. Shell Programming and Scripting
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
9. Shell Programming and Scripting
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
10. HP-UX
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
DIRNAME(3) 1 DIRNAME(3)
dirname - Returns parent directory's path
SYNOPSIS
string dirname (string $path)
DESCRIPTION
Given a string containing the path of a file or directory, this function will return the parent directory's path.
PARAMETERS
o $path
- A path. On Windows, both slash ( /) and backslash ( ) are used as directory separator character. In other environments, it is
the forward slash ( /).
RETURN VALUES
Returns the path of the parent directory. If there are no slashes in $path, a dot (' .') is returned, indicating the current directory.
Otherwise, the returned string is $path with any trailing /component removed.
CHANGELOG
+--------+-------------------------------+
|Version | |
| | |
| | Description |
| | |
+--------+-------------------------------+
| 5.0.0 | |
| | |
| | dirname(3) is now binary safe |
| | |
+--------+-------------------------------+
EXAMPLES
Example #1
dirname(3) example
<?php
echo "1) " . dirname("/etc/passwd") . PHP_EOL; // 1) /etc
echo "2) " . dirname("/etc/") . PHP_EOL; // 2) / (or on Windows)
echo "3) " . dirname("."); // 3) .
?>
NOTES
Note
dirname(3) operates naively on the input string, and is not aware of the actual filesystem, or path components such as " ..".
Note
dirname(3) is locale aware, so for it to see the correct directory name with multibyte character paths, the matching locale must be
set using the setlocale(3) function.
Note
Since PHP 4.3.0, you will often get a slash or a dot back from dirname(3) in situations where the older functionality would have
given you the empty string.
Check the following change example:
<?php
//before PHP 4.3.0
dirname('c:/'); // returned '.'
//after PHP 4.3.0
dirname('c:/x'); // returns 'c:'
dirname('c:/Temp/x'); // returns 'c:/Temp'
dirname('/x'); // returns ''
?>
SEE ALSO
basename(3), pathinfo(3), realpath(3).
PHP Documentation Group DIRNAME(3)