How to check path exist or not in UNIX shell script


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to check path exist or not in UNIX shell script
# 1  
Old 01-22-2008
How to check path exist or not in UNIX shell script

UNIX Shell Script
I'm in /home/suneel dirctory
in that directory need to check for a path for example com/src/resources
If Path exists need to copy the files from one directory
If path not exist need to create the folders and copy the files
UNIX shell script help required
# 2  
Old 01-22-2008
man test. Always check the man page first
# 3  
Old 01-22-2008
UNIX Shell Script
I'm in /home/suneel dirctory
in that directory need to check for a path for example com/src/resources
If Path exists need to copy the files from one directory
If path not exist need to create the folders and copy the files
UNIX shell script help required

[code]
#!/bin/bash
dir="dir path"
file="filename"
if [ -f $dir/$file ]
then
command
else
command
fi

[code]
# 4  
Old 01-22-2008
mkdir -p com/src/resources


Best Regards,
Rakesh UV
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to check email with attachment received or not from UNIX shell script?

Hello Guys, Here is the requirement!! I want to check the mail with attachment received or not through unix scripting. And send an notification email when mail with attachment already received. Any thoughts on this is much appreciated!! Regards, Harry (0 Replies)
Discussion started by: dharry2017
0 Replies

2. Shell Programming and Scripting

Check SQL through UNIX shell script

I use below command to log in to oracle database sqlplus username/passwordWhen i enter into sql prompt i press quitIf there are any errors it will show just below the output of sqlplus username/password. The errors generally start with keyword ORA can we do this by using a unix shell script.?... (4 Replies)
Discussion started by: Nakul_sh
4 Replies

3. Shell Programming and Scripting

Shell script to check files if exist else touch the file

Hi All, Thanks in Advance I wrote the following code if then echo "version is 1.1" for i in "subscriber promplan mapping dedicatedaccount faflistSub faflistAcc accumulator pam_account" do FILE="SDP_DUMP_$i.csv" echo "$FILE" ... (5 Replies)
Discussion started by: aealexanderraj
5 Replies

4. UNIX for Advanced & Expert Users

Shell script to check the SAN dual path.

Hello, I would like to create a shell script which would check whether the hosts have SAN dual path or not. If yes, then I should get a success message, else should get a list of hosts on which SAN dual path is not working. Thanks.. (4 Replies)
Discussion started by: mahive
4 Replies

5. Shell Programming and Scripting

Check file and if it doesnt exist , exit script

Hi, Another problem, here is my code #!/bin/sh dir='/opt/apps/script/CSV' datadir='/opt/apps/script/data' while : ; do ls -1rt $dir/*.csv > /dev/null 2>&1 if ;then cp $datadir/weekly.txt $dir/weekly.csv else exit 0 fi done (10 Replies)
Discussion started by: tententen
10 Replies

6. Shell Programming and Scripting

Review Check list for Unix Shell Script

Hi, I need Unix Shell Script Review Check list in the format of word or excel. Can any one provide the review checklist for unix shell script. Pls. (1 Reply)
Discussion started by: praka
1 Replies

7. Shell Programming and Scripting

how to check DB connection in unix shell script

In the following script I need to find whether DB is established successfully or not. I need to find and display it. If <DB is connected successfully> then echo "DB connection success" else echo "DB connection failure" fi In the same way I need to do it for DB terminate. I don't... (1 Reply)
Discussion started by: kmanivan82
1 Replies

8. UNIX for Dummies Questions & Answers

Need Script to check file exist and compare

I need a script that will check for the existence of new files that FTP'd in the morning, results go to log file. The 2nd step is to compare the new file with the previous days file. If the new file size is 30% or more smaller in size then previous day this needs to also be sent to log. This... (1 Reply)
Discussion started by: rbknisely
1 Replies

9. Shell Programming and Scripting

check in unix shell script so that no one is able to run the script manually

I want to create an automated script which is called by another maually executed script. The condition is that the no one should be able to manually execute the automated script. The automated script can be on the same machine or it can be on a remote machine. Can any one suggest a check in the... (1 Reply)
Discussion started by: adi_bang76
1 Replies

10. Shell Programming and Scripting

Have a shell script check for a file to exist before processing another file

I have a shell script that runs all the time looking for a certain type of file and then it processes the file through a series of other scripts. The script is watching a directory that has files uploaded to it via SFTP. It already checks the size of the file to make sure that it is not still... (3 Replies)
Discussion started by: heprox
3 Replies
Login or Register to Ask a Question