LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Closed Thread
  Search this Thread
Old 05-31-2011, 02:06 AM   #1
sahil.jammu
Member
 
Registered: Jun 2008
Distribution: Ubuntu
Posts: 83

Rep: Reputation: 15
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??

##################################################################################################
 
Old 05-31-2011, 02:11 AM   #2
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
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

Last edited by EricTRA; 05-31-2011 at 02:12 AM.
 
Old 05-31-2011, 04:57 AM   #3
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
This is a dupe. This is going to be closed. Now.
 
  


Closed Thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
can I get the absolute path without giving a "path" but a inode number by C? twwwater Programming 7 08-15-2010 08:16 PM
java applet not loading image with relative path but loads image with absolute path amolgupta Programming 2 07-20-2009 01:58 PM
Image Path reference in Linux (Absolute path) javabuddy Linux - General 7 06-05-2006 07:45 AM
script to change unix path to windows path in all files csross Programming 8 04-29-2006 01:05 PM
relative to absolute path vishalbutte Programming 4 01-14-2006 03:17 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration