Sponsored Content
Top Forums UNIX for Dummies Questions & Answers tar symlinks: relative vs absolute Post 302346320 by TreeMan on Friday 21st of August 2009 01:41:15 PM
Old 08-21-2009
Thanks for the reply. I tried to do this with mixed results. If the link was farther down the path, it woked, ie:

ln -s test/test/filea.txt filea.txt

This is restored no problem. But if I have a link like so:

ln -s ../test/filea.txt filea.txt

Then even though the parent dir and it's child 'test' are in the tar, the link is replaced with an actual copy of the file, so that an ls -al will show a file there now instead of a link. This does make sense to my why it would work this way, but I need it to not work that way. Smilie

Maybe tar is the wrong answer. I really just need to be able to archive up a bunch of files under /usr and then extract them under /tmp/test and have any links in there that used to point to /usr/... now point to /tmp/test/... Is this possible? The alternative will be to make a list of the symlinks using something like 'find . -type l' and then create a script to insert the symlinks after extraction. This is a less desirable option.

Thanks again

Edit: the less desirable option won. I made a script to go in and redo the absolute links so they use the new absolute path.

Last edited by TreeMan; 08-21-2009 at 05:58 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Relative directory - NOT absolute

Here is the drill, I am using a script to login to a remote ftp, and put and get files. My question is: I want to login and automatically change to the same directory I am in on my machine. I can not use $home, pwd or anyother env variable (that I know) since the names of the machines are totally... (4 Replies)
Discussion started by: sierra_aar
4 Replies

2. UNIX for Dummies Questions & Answers

vi - replacing a relative path with absolute path in a file

Hi, I have a file with about 60 lines of path: app-defaults/boxXYZ....... I want to change this to /my/path/goes/here/app-defaults/boxXYZ, but of course vi doesn't like the regualr :s/old/new/ command. Is there any other quick way to do this? Thanks ;) (2 Replies)
Discussion started by: Yinzer955i
2 Replies

3. Solaris

Extracting file from tar at relative location!!

Hi Gurus, I have a .tar file which required untar to the new location. I list the content with –tvf its listing the files which are inside the tar, when I am extracting he file from tar its working fine, however once I am trying to extract the file at the new location I am unable to do so. I... (11 Replies)
Discussion started by: kumarmani
11 Replies

4. UNIX for Dummies Questions & Answers

Absolute and Relative Paths?

Can someone cofirm that I have got the paths correct here? :confused: $PATH_TO_TMP_DIR='/tmp'; #$PATH_TO_TMP_DIR='home/tmp'; $PATH_TO_YOUR_IMG_DIR = '/temp_images'; #$PATH_TO_YOUR_IMG_DIR = 'home/public_html/Midwich/temp_images'; Thanks (1 Reply)
Discussion started by: stubie
1 Replies

5. Shell Programming and Scripting

absolute path for a script ran with relative path

I have a script in which i want to print absolute path of the same script irrespective of path from where i run script. I am using test.sh: echo "pwd : `pwd`" echo "script name: $0" echo "dirname: `dirname $0`" when i run script from /my/test/dir/struct as ../test.sh the output i... (10 Replies)
Discussion started by: rss67
10 Replies

6. UNIX for Advanced & Expert Users

accessing NFS absolute path symlinks from windows/cygwin

Hi experts, I was wondering if there is a way to access some NFS symlink files that are set using absolute paths from Windows? On windows/cygwin, I'm able to access relative path symlinks but not the absolute path symlinks. Assume on Linux (mylinux): /usr/local/file.c ln -s... (1 Reply)
Discussion started by: andredz
1 Replies

7. Shell Programming and Scripting

tar and relative paths

HOw can I create a tar file with relative paths find . -depth -print | xargs tar -cvf /tmp/file.tar ? Thanks to all who answer (1 Reply)
Discussion started by: BeefStu
1 Replies

8. UNIX for Dummies Questions & Answers

How to convert relative path to absolute path?

Hello Everyone, I want to convert Relative Path - /home/stevin/data/APP_SERVICE/../datafile.txt to Absolute Path - /home/stevin/data/datafile.txt Is there a built-in tool in Unix to do this or any good ideas as to how can I implement this. -Steve (5 Replies)
Discussion started by: qwarentine
5 Replies

9. Shell Programming and Scripting

Show only the filenames under a directory without relative and absolute paths.

I am able to list all the filenames under a directory & its sub-directories except blent.tar on Linux find "/tmp/" -type f | grep -v blent.tar | rev | cut -d '/' -f1 | rev Desired Output: THIRDPARTYLICENSEREADME.txt javaws libjavaplugin_oji.so libjavaplugin_oji.so... (3 Replies)
Discussion started by: mohtashims
3 Replies

10. UNIX for Beginners Questions & Answers

Convert Relative path to Absolute path, without changing directory to the file location.

Hello, I am creating a file with all the source folders included in my git branch, when i grep for the used source, i found source included as relative path instead of absolute path, how can convert relative path to absolute path without changing directory to that folder and using readlink -f ? ... (4 Replies)
Discussion started by: Sekhar419
4 Replies
DH_LINK(1)							     Debhelper								DH_LINK(1)

NAME
       dh_link - create symlinks in package build directories

SYNOPSIS
       dh_link [debhelperoptions] [-A] [-Xitem] [sourcedestination...]

DESCRIPTION
       dh_link is a debhelper program that creates symlinks in package build directories.

       dh_link accepts a list of pairs of source and destination files. The source files are the already existing files that will be symlinked
       from (called target by ln(1)). The destination files are the symlinks that will be created (called link name by ln(1)). There must be an
       equal number of source and destination files specified.

       Be sure you do specify the absolute path to both the source and destination files (unlike you would do if you were using something like
       ln(1)).	Please note that the leading slash is optional.

       dh_link will generate symlinks that comply with Debian policy - absolute when policy says they should be absolute, and relative links with
       as short a path as possible. It will also create any subdirectories it needs to put the symlinks in.

       Any pre-existing destination files will be replaced with symlinks.

       dh_link also scans the package build tree for existing symlinks which do not conform to Debian policy, and corrects them (v4 or later).

FILES
       debian/package.links
	   Lists pairs of source and destination files to be symlinked. Each pair should be put on its own line, with the source and destination
	   separated by whitespace.

	   In each pair the source file (called target by ln(1)) comes first and is followed by the destination file (called link name by ln(1)).
	   Thus the pairs of source and destination files in each line are give in the same order as they would be given to ln(1).

	   In contrast to ln(1), source and destination paths must be absolute (the leading slash is optional).

OPTIONS
       -A, --all
	   Create any links specified by command line parameters in ALL packages acted on, not just the first.

       -Xitem, --exclude=item
	   Exclude symlinks that contain item anywhere in their filename from being corrected to comply with Debian policy.

       source destination ...
	   Create a file named destination as a link to a file named source. Do this in the package build directory of the first package acted on.
	   (Or in all packages if -A is specified.)

EXAMPLES
	dh_link usr/share/man/man1/foo.1 usr/share/man/man1/bar.1

       Make bar.1 be a symlink to foo.1

	dh_link var/lib/foo usr/lib/foo 
	  usr/share/man/man1/foo.1 usr/share/man/man1/bar.1

       Make /usr/lib/foo/ be a link to /var/lib/foo/, and bar.1 be a symlink to the foo.1

	var/lib/foo usr/lib/foo
	usr/share/man/man1/foo.1 usr/share/man/man1/bar.1

       Same as above but as content for a debian/package.links file.

SEE ALSO
       debhelper(7)

       This program is a part of debhelper.

AUTHOR
       Joey Hess <joeyh@debian.org>

11.1.6ubuntu2							    2018-05-10								DH_LINK(1)
All times are GMT -4. The time now is 06:30 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy