www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2010/11/06/10:12:56

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=0.8 required=5.0 tests=BAYES_50,RCVD_IN_DNSWL_NONE
X-Spam-Check-By: sourceware.org
Message-Id: <6488B010-E946-4EA3-BE77-586ACD794EEB@edgar-matzinger.nl>
From: Edgar Matzinger <edgar AT edgar-matzinger DOT nl>
To: cygwin AT cygwin DOT com
In-Reply-To: <ib3gtb$v4$1@dough.gmane.org>
Mime-Version: 1.0 (Apple Message framework v936)
Subject: Re: cp: omitting directory, for copying only files, sed
Date: Sat, 6 Nov 2010 15:12:27 +0100
References: <ib3gtb$v4$1 AT dough DOT gmane DOT org>
X-Pgp-Agent: GPGMail 1.2.0 (v56)
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi David,

On 6 Nov 2010, at 13:15, David wrote:

> I have a script:
>
> #!/bin/bash
> W=3D"\/cygdrive\/c\/Users\/dbj\/workspace\/$1\/."

Why do you escape the directory separators?

> echo $W
> sed -n 's/^File[ ]*\([^ ][^ ]*\).*/\"\1\" '"$W"'/p' < $2 | xargs cp

Oh, you're using '/' as string delimiter. Use ':'. I.e.:
sed -n 's:/^File...:\1...:p'

>
> Then I do
>
> $ ./cptest1.sh test list.txt
> \/cygdrive\/c\/Users\/dbj\/workspace\/test\/.
> cp: omitting directory `/cygdrive/c/Users/dbj/workspace/test/.'
>
> Why do I get "cp: omitting directory"?

I ran this script (on MacOSX):

#!/bin/sh
W=3D"\/Users\/edgarm\/tmp\/$1\/."
echo $W
sed -n 's/^File[ ]*\([^ ][^ ]*\).*/\"\1\" '"$W"'/p' < $2 | xargs echo X:

And this is the output...

tmp$ ./cptest1 test list.txt
\/Users\/edgarm\/tmp\/test\/.
X: ..\test\file1.txt /Users/edgarm/tmp/test/. ..\test\file2.txt /Users/=20
edgarm/tmp/test/.

See the problem?

Regards, Edgar Matzinger.
- --
                                                         ''~``
                                                        ( o o )
+-------------------------------------------------.oooO--(_)--Oooo.---+

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Darwin)

iQEcBAEBAgAGBQJM1WJMAAoJEENMxv7g8VYwX0sH/2qMyYX0FK/GVEz1dcXkuxV0
mbBTCjcwOmd7fBcoSgWCjctkYYI9pS3RqCJaEk9C1JU+aWLdGJd5rk1SubAsk+en
usgkUSUDePq/+oU8RR4ZQhBNkhj60j+4aFieAjLxO3ZtWjp8U1P8JSVPNcDIwavo
f0dYDI/ivKj0BmpBe/rYbuJ2G3UIs2vivkKZXrRDNC21otBArb4HS84S3alc6M+E
vgk1r0gKBrBjDHp7tCIQNZ5bYob6x6mQdtqHZFgnx1/SJ9L5Db5lEkx4BcxLCCC3
FPm6msjZcDKy/OJYGTLYFvT6Tn+6hI5nPERO9pxERKGvrhnIt41i8w16YzIaVfo=3D
=3DIErD
-----END PGP SIGNATURE-----

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019