From: Sashi on
All, I've got a directory with a bunch of files. I want to move
certain files into a different directory. The list of files is in a
text file.
When I try to do it in a for loop

for file in $(cat routers); do cp $file ../configs/.; done

I'm getting a message saying:
cp: cannot stat `russwdc-cpv21-7206\r': No such file or directory

I'm not sure how to get rid of the '\r' here.

Can someone help out?

Thanks,
Sashi
From: Gary Johnson on
Sashi <smalladi(a)gmail.com> wrote:
> All, I've got a directory with a bunch of files. I want to move
> certain files into a different directory. The list of files is in a
> text file.
> When I try to do it in a for loop
>
> for file in $(cat routers); do cp $file ../configs/.; done
>
> I'm getting a message saying:
> cp: cannot stat `russwdc-cpv21-7206\r': No such file or directory
>
> I'm not sure how to get rid of the '\r' here.
>
> Can someone help out?

You created the 'routers' file using a program that ends each line with
the DOS-style CR-LF. Bash expects lines to end with only LF so it
treats the CR ('\r') as part of the line. In your case, that CR becomes
part of the file name.

To fix that in Cygwin, you can use the 'd2u' program to convert DOS line
endings to Unix line endings, e.g.,

d2u routers

--
Gary Johnson
From: Sashi on
On May 6, 7:24 pm, Janis Papanagnou <Janis_Papanag...(a)hotmail.com>
wrote:
> Sashi wrote:
> > All, I've got a directory with a bunch of files. I want to move
> > certain files into a different directory.
>
> This Cygwin environment (or rather the WinDOS environment) can be a pain.
>
> > The list of files is in a
> > text file.
> > When I try to do it in a for loop
>
> > for file in $(cat routers); do cp $file ../configs/.; done
>
> > I'm getting a message saying:
> > cp: cannot stat `russwdc-cpv21-7206\r': No such file or directory
>
> > I'm not sure how to get rid of the '\r' here.
>
> > Can someone help out?
>
> I'd try the following...
>
> dos2unix routers
>
> while read file
> do cp "$file" ../configs/
> done < routers
>
> Janis
>
>
>
> > Thanks,
> > Sashi

I should've known..
Thanks!
Sashi