Sponsored Content
Top Forums Shell Programming and Scripting Move directory recursive and leave symlinks at source Post 303009428 by MadeInGermany on Thursday 14th of December 2017 10:26:25 AM
Old 12-14-2017
Always check the exit status of a cd command!
Code:
cd /original &&
tar -cvf - . | (cd /target && tar -xvpf - )

An generic version is
Code:
(cd /original && tar -cvf - .) | (cd /target && tar -xvpf - )

where both the sending and the receiving tar work in certain directories in a subshell, while the current directory in the main shell is unchanged.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

non recursive search in the current directory only

Hi, Am trying for a script which should delete more than 15 days older files in my current directory.Am using the below piece of code: "find /tmp -type f -name "pattern" -mtime +15 -exec /usr/bin/ls -altr {} \;" "find /tmp -type f -name "pattern" -mtime +15 -exec /usr/bin/rm -f {} \;" ... (9 Replies)
Discussion started by: puppala
9 Replies

2. Programming

recursive copy of the directory

I want to copy a directory recursively ( it again has directories) and the directory is on windows and is nfsmounted in vxWorks, i am using unix to develop the code for this, can any one suggest me how to copy the directories recursively. (7 Replies)
Discussion started by: deepthi.s
7 Replies

3. Programming

Recursive remove directory.

What is the best way to completely remove dir with it's content ??? rmdir deletes only EMPTY dirs as i know. The man page of remove function says "remove() deletes a name from the file system." Can it remove any dir recursively ??? :rolleyes: (7 Replies)
Discussion started by: Trump
7 Replies

4. UNIX for Dummies Questions & Answers

recursive wc on a directory?

Hi all, I need to count the number of lines in all the files under a directory (several levels deep). I am feeling extremely dumb, but I don't know how to do that. Needless to say, I am not a shell script wiz... Any advice? thanks in advance! (13 Replies)
Discussion started by: bimba17
13 Replies

5. Shell Programming and Scripting

Move all files from source to destination directory based on the filename

Move all files starting with a specific name to different directory. This shell script program should have three parameters File Name Source Directory Destination Directory User should be able to enter ‘AB_CD*' in file name parameter. In this case all the files starting with AB_CD will... (1 Reply)
Discussion started by: chetancrsp18
1 Replies

6. Shell Programming and Scripting

Rsync move with symlinks

Hi, I use rsync to move from source to target, but there are cases that I need to exclude: Suppose in my file system, I have a soft link ~/data -> /media/volgrp/data. Under data folder, there is a file hello.txt. After moving command "rsync --remove-source-files -aH --force ~/data/... (3 Replies)
Discussion started by: huangyingw
3 Replies

7. Shell Programming and Scripting

List files with date, create directory, move to the created directory

Hi all, i have a folder, with tons of files containing as following, on /my/folder/jobs/ some_name_2016-01-17-22-38-58_some name_0_0.zip.done some_name_2016-01-17-22-40-30_some name_0_0.zip.done some_name_2016-01-17-22-48-50_some name_0_0.zip.done and these can be lots of similar files,... (6 Replies)
Discussion started by: charli1
6 Replies

8. UNIX for Dummies Questions & Answers

How to move gz files from one source directory to destination directory?

Hi All, Daily i am doing the house keeping in one of my server and manually moving the files which were older than 90 days and moving to destination folder. using the find command . Could you please assist me how to put the automation using the shell script . ... (11 Replies)
Discussion started by: venkat918
11 Replies

9. Shell Programming and Scripting

Shell script cannot create directory and move the file to that directory

I have a script, which is checking if file exists and move it to another directory if then mkdir -p ${LOCL_FILES_DIR}/cool_${Today}/monthly mv report_manual_alloc_rpt_A_I_ASSIGNMENT.${Today}*.csv ${LOCL_FILES_DIR}/cool_${Today}/monthly ... (9 Replies)
Discussion started by: digioleg54
9 Replies

10. UNIX for Beginners Questions & Answers

Move directory with rsync and delete from source

I need a rsync command which will exclude certain files and directories from source and copy the rest. I got this command working, sudo rsync -avzh --exclude 'bin' --exclude 'braintree' --exclude 'colinmollenhour' --exclude 'composer' --exclude 'doctrine' --exclude 'fabpot' --exclude... (2 Replies)
Discussion started by: Siddheshk
2 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 09:38 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy