String Manipulation question!
I have a string and keeping the delimiter to be /, I would like extract highlighted string
/u01/oradata/mydatabase/ABCF.dbf I can extract the last field after the delimiter, but all the fields before is the challenge to me. Thanks Nirmal |
Ok I figured out
basename /u01/oradata/mydatabase/ABCF.dbf gives me ABCF.dbf dirname /u01/oradata/mydatabase/ABCF.dbf gives me /u01/oradata/mydatabase Cheers... |
Try this.
Code:
echo "/u01/oradata/mydatabase/ABCF.dbf" | awk -F"/" '{print "/"$1"/"$2"/"$3}' |
Or if you actually want to use string manipulation in bash:
Code:
LINE="/u01/oradata/mydatabase/ABCF.dbf" |
Or sed:
Code:
sed 's/^\(.*\)/[^/]*$/\1/' If the issue is solved, mark the thread as solved. |
Vikas, you suggested:
echo "/u01/oradata/mydatabase/ABCF.dbf" | awk -F"/" '{print "/"$1"/"$2"/"$3}' In my case I don't know how many fields are there. It would be 3,4 or 5 and who know. Thanks Nirmal |
Quote:
|
Quote:
|
All times are GMT -5. The time now is 11:56 AM. |