![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to get path and check in if statement | eltinator | Shell Programming and Scripting | 6 | 04-08-2008 09:39 PM |
| How to check path exist or not in UNIX shell script | suneelc | UNIX for Dummies Questions & Answers | 3 | 01-22-2008 08:36 AM |
| Check whether the pattern is present or not? | skyineyes | Shell Programming and Scripting | 8 | 06-27-2007 09:42 AM |
| swap file not present | Naanu | SUN Solaris | 7 | 04-06-2007 07:56 PM |
| how to check the actual path instead of link path | reldb | UNIX for Advanced & Expert Users | 4 | 10-04-2006 09:55 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
how to check if path is present?
following situation...
- bourne shell script - sb. should entry a path and the script should look if the path exists, when not it should restart the Input ... echo "path\c" read Inp if [$Inp = ?????] ; then echo " path doesn't exist, try again... " (how to go back to the Inp?????) else echo " path exists " ..... fi ... thx for any advice... |
|
||||
|
is there a chance by 'pathchk'? for example...
echo "path\c" read Inp>file VALID=pathchk `cat file` if [$VALID != 0] ; then echo " path doesn't exist, try again... " (how to go back to the Inp?????) else echo " path exists " .......... fi .. is there also sth. like for files? like checking if the file is present and then return a zero..... |
|
||||
|
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 .. |
|
||||
|
no help needed anymore...thx
The test command evaluates the expression expr and, if its value is True, returns a zero (true) exit status; otherwise, a nonzero (false) exit status is returned. test also returns a nonzero exit status if there are no arguments. The following primitives are used to construct expr: -r file True if file exists and is readable. -w file True if file exists and is writable. -x file True if file exists and is executable. -f file True if file exists and is a regular file. -d file True if file exists and is a directory. -c file True if file exists and is a character special file. -b file True if file exists and is a block special file. -p file True if file exists and is a named pipe (fifo). -u file True if file exists and its set-user-ID bit is set. -g file True if file exists and its set-group-ID bit is set. -k file True if file exists and its sticky bit is set. -s file True if file exists and has a size greater than zero. -h file True if file exists and is a symbolic link. -t [fildes] True if the open file whose file descriptor number is fildes (1 by default) is associated with a terminal device. -z s1 True if the length of string s1 is zero. -n s1 True if the length of the string s1 is non-zero. s1 = s2 True if strings s1 and s2 are identical. s1 != s2 True if strings s1 and s2 are not identical. s1 True if s1 is not the null string. n1 -eq n2 True if the integers n1 and n2 are algebraically equal. Any of the comparisons -ne, -gt, -ge, -lt, and -le can be used in place of -eq. These primaries can be combined with the following operators: ! Unary negation operator. -a Binary AND operator. -o Binary OR operator (-a has higher precedence than -o). ( expr ) Parentheses for grouping. ------ by the way, go back to the Input by while->break.... ------ also have a look here... http://www.washington.edu/computing/...g/125/ctl.html |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|