You are not logged in.

#1 2019-07-03 20:19:38

StopkaPeter
Member
From: Slovakia
Registered: 2019-05-20
Posts: 31

[Solved] Strange result after using rsync in bash script

Hi, when I run this command in terminal:

rsync -aAVx /var /data/backup/

everything works as I expected, directory var is copied to directory /data/backup/ and result is /data/backup/var.

But when I create simple shell script rsync.sh:

#!/bin/bash
rsync -aAVx /var /data/backup/

and run under terminal with command:

bash rsync.sh

I get strange result in directory /data/backup/ where new folder name is ''$'\r' or with tab-completion ^M:

ls -l
drwxr-xr-x 3 root root 4096 Jul 3 21:00 ''$'\r'

What am I doing wrong. Thank you.

Last edited by StopkaPeter (2019-07-03 23:13:08)

Offline

#2 2019-07-03 20:39:01

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: [Solved] Strange result after using rsync in bash script

What text editor did you use to create the script?

Also, don't name your scripts after existing utilities: it will break something at some point.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2019-07-03 22:04:38

StopkaPeter
Member
From: Slovakia
Registered: 2019-05-20
Posts: 31

Re: [Solved] Strange result after using rsync in bash script

jasonwryan wrote:

What text editor did you use to create the script?

When you mentioned this, it was clear right away. Problem was because I wrote scripts in windows and final files I transferred over usb in to Arch. After recreated scripts under linux, everything works for now. Thank you for tip.

Offline

#4 2019-07-03 22:16:30

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: [Solved] Strange result after using rsync in bash script

Please remember to mark your thread as [Solved] by editing your first post and prepending it to the title.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

Board footer

Powered by FluxBB