LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to change Absolute path to Relative path (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-change-absolute-path-to-relative-path-883658/)

sahil.jammu 05-31-2011 02:06 AM

How to change Absolute path to Relative path
 
Hello,

I have a doubt:-

---------------------
Current script:-

################################################################################################
prefix=user@my-server:
find . -depth -type d -name .git -printf '%h\0' | while read -d "" path ; do (
cd "$path" || exit $?
name="`basename "$path"`"
echo <command> "$prefix$PWD.git"
) done
#################################################################################################
Output:-
<command> user@my-server:/home/git/mirror/android/adb/OpenWnn.git
<command> user@my-server:/home/git/mirror/android/adb/cts.git
<command> user@my-server:/home/git/mirror/android/adb/dalvik.git
<command> user@my-server:/home/git/mirror/android/adb/ndk.git
#################################################################################################

Desired output:-
<command> user@my-server:/android/adb/OpenWnn.git
<command> user@my-server:/mirror/android/adb/cts.git
<command> user@my-server:/android/adb/dalvik.git
<command> user@my-server:/mirror/android/adb/ndk.git

##################################################################################################


How shall i go about changing the absolute path to relative path, so that /home/git/mirror/android/adb/ndk.git
gets converted to /mirror/android/adb/ndk.git

//echo <command> "$prefix$PWD.git" ?? - anything for relative path??

##################################################################################################

EricTRA 05-31-2011 02:11 AM

Hello,

Please don't double post your question. It'll only confuse both you and us on where the conversation is taking place. Reported since it's a duplicate for this one.

Kind regards,

Eric

colucix 05-31-2011 04:57 AM

This is a dupe. This is going to be closed. Now.


All times are GMT -5. The time now is 10:54 PM.