Sponsored Content
Top Forums UNIX for Dummies Questions & Answers how to check if path is present? Post 57567 by svennie on Tuesday 2nd of November 2004 05:04:32 AM
Old 11-02-2004
for example for files...

echo "path\c"
read Inp1>file1
VALID1=pathchk `cat file1`
if [$VALID1 != 0] ; then
echo " path doesn't exist, try again... "
(how to go back to the Inp1?????)
else
echo " path exists "
cd `cat file1` (will not work, because of the directory..how to solve?)
cd `cat users/abc/file1`(should work)
echo "searching which file? \c"
read Inp2
find . -name "`cat file2`" >file3
VALID2=`cat file3`
if [ -f $VALID2 ] ; then
echo "$VALID2 exists"
....
else
echo "not existing"
(how to go back to the Inp2?????)
fi
..
fi
..
 

9 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

how to check the actual path instead of link path

Hi I have a path link /test/df/link1/actual/file1 here link1 is actually a softlink link1= a/b i need to print the ACTUAL FULL path instead of a linked path is there any direct command to print the actual path of any linked path eg showPhyscialPath /test/df/link1/actual/file1 and it... (4 Replies)
Discussion started by: reldb
4 Replies

2. Shell Programming and Scripting

Check whether the pattern is present or not?

I want to determine whether a specific pattern is present within a line or not e.g. The whole line is in a varaible called VALUE VALUE="(ABC, DEF, NMF, ABC, CLF, PAR, FHG, AGQSAs, sada, sa, ABC)" i want to set a flag to 1 if i find the presence of ABC in the above variable. Please... (8 Replies)
Discussion started by: skyineyes
8 Replies

3. Shell Programming and Scripting

How to get path and check in if statement

Hi, I was wondering if it possible to get the path of a variable and compare that to something. Basically I want to write a script that checks if my $JAVA_HOME is correct and if not then it sets it. So far I have... if ] then export JAVA_HOME='/pathhere' echo JAVA_HOME='/pathhere' fi ... (6 Replies)
Discussion started by: eltinator
6 Replies

4. Shell Programming and Scripting

check if specified path is in $PATH

echo $PATH | grep "\/usr\/ucb" is not working using sh-posix The problem is very simle. I want to check '/usr/ucb' is in the PATH environment variable. If i simply grep '/usr/ucb' i might got wrong result eg '/usr/ucb/bin'. After the path an end of line or colon character should be. In... (4 Replies)
Discussion started by: fpeter75
4 Replies

5. Shell Programming and Scripting

How to check the variable is present in array or not ?

Hi , I am trying to check wether the variable is present in the array. please see the below code .when ever i do this its taking only the first value of the array . please advise. ###Code Snnipet ### #!/bin/ksh set -xv if ]; then echo " you have Specified the ORG ID - $1 " ... (1 Reply)
Discussion started by: padhu.47
1 Replies

6. Shell Programming and Scripting

check whether 3 files are present

I'm trying to check whether 3 files are existing and send 3 files as attachements. If only two are there then send those two files as attachments. if ; then elif ; then I tired the above given syntax and then it is giving me an error line 11: ' I tried with -a instead of && and... (3 Replies)
Discussion started by: Celvin VK
3 Replies

7. Shell Programming and Scripting

How to Check whether list file present in TXT file exist or not

Hi All, I have txt file which has list of files. I have to check whether these files exist or not. Thanks supriya (6 Replies)
Discussion started by: supriyabv
6 Replies

8. UNIX for Dummies Questions & Answers

Present Working Directory (not the full path)

Hi, Is there a command that tells you right away the current working directory? I know the command "pwd", but that one gives the full path. if pwd gives me: /a/b/c/d/ggg/HERE I want something that will give me: HERE Thanks, Gaurab (13 Replies)
Discussion started by: gaurab
13 Replies

9. Shell Programming and Scripting

List all the files in the present path and Folders and subfolders files also

Hi, I need a script/command to list out all the files in current path and also the files in folder and subfolders. Ex: My files are like below $ ls -lrt total 8 -rw-r--r-- 1 abc users 419 May 25 10:27 abcd.xml drwxr-xr-x 3 abc users 4096 May 25 10:28 TEST $ Under TEST, there are... (2 Replies)
Discussion started by: divya bandipotu
2 Replies
SHTOOL-PATH.TMP(1)					      GNU Portable Shell Tool						SHTOOL-PATH.TMP(1)

NAME
shtool-path - GNU shtool command dealing with shell path variables SYNOPSIS
shtool path [-s|--suppress] [-r|--reverse] [-d|--dirname] [-b|--basename] [-m|--magic] [-p|--path path] str [str ...] DESCRIPTION
This command deals with shell $PATH variables. It can find a program through one or more filenames given by one or more str arguments. It prints the absolute filesystem path to the program displayed on "stdout" plus an exit code of 0 if it was really found. OPTIONS
The following command line options are available. -s, --suppress Supress output. Useful to only test whether a program exists with the help of the return code. -r, --reverse Transform a forward path to a subdirectory into a reverse path. -d, --dirname Output the directory name of str. -b, --basename Output the base name of str. -m, --magic Enable advanced magic search for ""perl"" and ""cpp"". -p, --path path Search in path. Default is to search in $PATH. EXAMPLE
# shell script awk=`shtool path -p "${PATH}:." gawk nawk awk` perl=`shtool path -m perl` cpp=`shtool path -m cpp` revpath=`shtool path -r path/to/subdir` HISTORY
The GNU shtool path command was originally written by Ralf S. Engelschall <rse@engelschall.com> in 1998 for Apache. It was later taken over into GNU shtool. SEE ALSO
shtool(1), which(1). 18-Jul-2008 shtool 2.0.8 SHTOOL-PATH.TMP(1)
All times are GMT -4. The time now is 04:09 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy