Shell $,/r getting added in echo on variable substitution.

Hi All,

I'm trying to run a similar script to copy a files from one location to another.

#!/bin/bash
source="/home/pradeepk/a.txt"
destination="/home/pradeepk/dir1"
cp $source $destination

i'm getting following error.

cp: cannot stat `/home/pradeepk/a.txt\r': No such file or directory

when i debug this i found this output.

+ source=$'/home/pradeepk/a.txt\r'
+ destination=$'/home/pradeepk/dir1\r'
+ cp $'/home/pradeepk/a.txt\r' $'/home/pradeepk/dir1\r'
cp: cannot stat `/home/pradeepk/a.txt\r': No such file or directory

Can anyone help me on this..?

Thanks in advance.
Pradeep Kumar.

Use a Unix/Linux editor or remove the Carriage Returns with:

tr -d '\r' < dosfile > unixfile