I am working on shell script and I want to get a pattern in a string starts and ends with a specific character. As much as I can do was:
a=`grep -oh ^\/ $1`
grep -oh \'$ $a
I know that grep -oh
command finds a word in a file and prints it so I tried to find the words starts with /
and ends with '
.
But it still finds words, but I need patterns to find, like if /bin/ls'dir
is the string, I have to get /bin/ls. Also like this I can not suppress '
character at the end.
How could it be done?