|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
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 out? Thanks, Sashi |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
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 out? I'd try the following... dos2unix routers while read file do cp "$file" ../configs/ done < routers Janis > > Thanks, > Sashi |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
Sashi <smalladi@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 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 |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
On May 6, 7:24 pm, Janis Papanagnou <Janis_Papanag...@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 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 |
|
![]() |
| Outils de la discussion | |
|
|