LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Another modification of a variable (https://www.linuxquestions.org/questions/linux-newbie-8/another-modification-of-a-variable-649930/)

pdklinux79 06-17-2008 12:38 PM

Another modification of a variable
 
name=/data/cur/00000.chd.hgt

now i need to remove /data/cur and want the vairable as
name=0000.chd.hgt

i tried cut but it didnt work for me. can anyone let me know how to do it?
thanks

colucix 06-17-2008 12:41 PM

This is a task for the basename command:
Code:

name=$(basename $name)
See man basename for details. Or, without calling an external command:
Code:

name=${name##*/}
This strip the longest part of the pattern that matches the front of the string, where the pattern is any sequence of characters followed by slash "*/".

pdklinux79 06-17-2008 12:50 PM

Thanks . it is working.


All times are GMT -5. The time now is 12:47 AM.