Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rsync to get a list of only file names

Here's an example of the command I'm using:

rsync --list-only --include "*2012*.xml" -exclude "*.xml" serveripaddress::pt/dir/files/ --port=111 > output.txt

How can I get a listing of just the file names without the extra information like permissions, timestamp, etc.?

Edit: And is it possible to output each file name on a new line?

like image 520
user1172282 Avatar asked Feb 01 '12 19:02

user1172282


2 Answers

After years of work, here is my solution to this age-old problem:

DIR=`mktemp -d /tmp/rsync.XXXXXX`
rsync -nr --out-format='%n' serveripaddress::pt/dir/files/ $DIR > output.txt
rmdir $DIR
like image 159
William Entriken Avatar answered Oct 14 '22 05:10

William Entriken


Further to https://stackoverflow.com/a/29522388/2858703

If your mktemp supports the --dry-run option, there's no need to actually create the temporary directory:

rsync -nr --out-format='%n' serveripaddress::pt/dir/files/ $(mktemp -d --dry-run) > output.txt
like image 40
bxm Avatar answered Oct 14 '22 07:10

bxm