LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   bash string manipulation (http://www.linuxquestions.org/questions/programming-9/bash-string-manipulation-562501/)

kpachopoulos 06-17-2007 04:52 PM

bash string manipulation
 
Hi,
how can i change "../dir" to "/dir"?

Thanks

macemoneta 06-17-2007 05:13 PM

You can use a substring function:

Code:

someVar=${someVar:2}
The above takes the substring of the variable ("someVar") starting at the third character (0-based).

Centinul 06-17-2007 05:15 PM

Here ya go:

Code:

echo "../dir" | sed -e 's/\.\.//g'
HTH,

Centinul

ghostdog74 06-17-2007 06:45 PM

bash comes with its own string substitution, there's no need to call external commands.
Code:

echo ${var//./}


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