![]() |
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 Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to check if a variable contains a . | gekkos | Shell Programming and Scripting | 3 | 11-27-2008 03:00 PM |
| how to check string of character | manas_ranjan | Shell Programming and Scripting | 9 | 05-12-2008 07:20 AM |
| read string, check string length and cut | ozzy80 | Shell Programming and Scripting | 9 | 03-21-2007 05:56 PM |
| check whether variable number or string | rolex.mp | UNIX for Dummies Questions & Answers | 4 | 02-22-2007 12:12 AM |
| How to check a string in the variable | josephwong | Shell Programming and Scripting | 1 | 06-26-2006 12:14 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
If "$y" always comes at the end of "$x" and (you said the content is a path) is preceeded by a slash ("/") you could use the shells variable expansion feature to trim "$x" accordingly and compare if it equals to "$y". "${x##*/}" suppresses every content of "$x" up to the last slash:
Code:
x="/a/b/c/d/e"
y="f" # comment this, uncomment the following line and run again
# y="e"
if [ "${x##*/}" = "$y" ] ; then
echo "x and y are equal"
else
echo "x and y are different"
fi
i hope this helps. bakunin |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Tags |
| awk, awk trim, trim, trim awk |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|