Re: use the list of files stored in a text file and process it

2010-10-01 Thread Csaba Raduly
On Thu, Sep 30, 2010 at 3:37 PM, SJ Wright  wrote:
 I know one of the trip-ups I often have if I spend any time away from a
 L/Unix environment has to do with the mv command: I often forget that it
 prefers absolute paths from root folders (or in the case of Cygwin, virtual
 ones taken as real) or dot-dot-slash relative path syntax to just
 /god-directory/ or what-have-you. Many other commands, particularly ls and
 ln -s, are likewise particular about their paths.

(general you meant below)
Unix commands are not particular about their paths. They just trust
you to give the correct file names. If the file name does not begin
with a slash, it is relative to the current directory. That may or may
not be what you intended. Using absolute paths ensures that the
meaning of a filename is not influenced by the current directory; but
using relative paths is often shorter. If you have trouble remembering
what the current directory is, try setting the prompt to always print
the current directory, like this:

 PS1='\[\e]0;\w\a\]\n\[\e[32m\...@\h \[\e[33m\]\w\[\e[0m\]\n\t \$ '

-- 
GCS a+ e++ d- C++ ULS$ L+$ !E- W++ P+++$ L w++$ tv+ b++ DI D++ 5++
Life is complex, with real and imaginary parts.
Ok, it boots. Which means it must be bug-free and perfect.  -- Linus Torvalds
People disagree with me. I just ignore them. -- Linus Torvalds

--
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



Re: use the list of files stored in a text file and process it

2010-10-01 Thread SJ Wright

Csaba Raduly wrote:

On Thu, Sep 30, 2010 at 3:37 PM, SJ Wright  wrote:
  

I know one of the trip-ups I often have if I spend any time away from a
L/Unix environment has to do with the mv command: I often forget that it
prefers absolute paths from root folders (or in the case of Cygwin, virtual
ones taken as real) or dot-dot-slash relative path syntax to just
/god-directory/ or what-have-you. Many other commands, particularly ls and
ln -s, are likewise particular about their paths.



(general you meant below)
Unix commands are not particular about their paths. They just trust
you to give the correct file names. If the file name does not begin
with a slash, it is relative to the current directory. That may or may
not be what you intended. Using absolute paths ensures that the
meaning of a filename is not influenced by the current directory; but
using relative paths is often shorter. If you have trouble remembering
what the current directory is, try setting the prompt to always print
the current directory, like this:

 PS1='\[\e]0;\w\a\]\n\[\e[32m\...@\h \[\e[33m\]\w\[\e[0m\]\n\t \$ '

  
Careless of me to promulgate a baseless assertion. Cygwin and Unix are 
simply tools: they can do no more, and be credited or blamed with no 
more, than their makers or users direct them or design them to do.


SJ Wright


--
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



Re: use the list of files stored in a text file and process it

2010-09-30 Thread Henry S. Thompson
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

You will also run into problems with xargs and filenames with spaces
in.  In my experience, the simplest thing that works reliably with
xargs and all Windoz filenames is xargs -0, so what you want is

 tr -s '\012\015' '\000'  test.txt | xargs -0 ls

Note also that find has a -print0 flag, which goes well with -0

 find . -name '[whatever]' ... -print0 | xargs -0 ...

ht
- -- 
   Henry S. Thompson, School of Informatics, University of Edinburgh
  10 Crichton Street, Edinburgh EH8 9AB, SCOTLAND -- (44) 131 650-4440
Fax: (44) 131 651-1426, e-mail: h...@inf.ed.ac.uk
   URL: http://www.ltg.ed.ac.uk/~ht/
 [mail from me _always_ has a .sig like this -- mail without it is forged spam]
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.6 (GNU/Linux)

iD8DBQFMpEHTkjnJixAXWBoRAvcjAJ4uo9c819hzVbbVovyTN8z4+/g2HQCfShCC
pFsvAO0QacPuXcIQjsKqWVY=
=9ZJi
-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



Re: use the list of files stored in a text file and process it

2010-09-30 Thread SJ Wright

albert kao wrote:

I store a list of files in a text file (test.txt) on Windows XP.
I want to use the list of files and process it (e.g. ls).
What is the command to do that?
I tried the following commands but to no avail.

$ cat test.txt
test.txt

$ cat test.txt | xargs ls
: No such file or directory

$ cat test.txt | xargs -delimiter=\n ls
xargs: Invalid input delimiter specification elimiter=\n: the delimiter must be 
either a single char

acter or an escape sequence starting with \.

$ cat test.txt | xargs -delimiter='\n' ls
xargs: Invalid input delimiter specification elimiter=\n: the delimiter must be 
either a single char

acter or an escape sequence starting with \.

$ cat test.txt | xargs -delimiter='\\n' ls
xargs: Invalid input delimiter specification elimiter=\\n: the delimiter must be 
either a single cha

racter or an escape sequence starting with \.

$ cat test.txt | xargs -delimiter=\\n ls
xargs: Invalid input delimiter specification elimiter=\n: the delimiter must be 
either a single char

acter or an escape sequence starting with \.

$ uname -srv
CYGWIN_NT-5.1 1.7.5(0.225/5/3) 2010-04-12 19:07



--
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


  
I would also suggest that you check your filenames in test.txt to make 
sure, if you included paths, that they are absolute and follow the 
Cygwin virtual-paths (cygpath) syntax, i.e.: /cygdrive/c/... or 
/etc/share/... and so on. Barring that, a path in Unix notation relative 
to your $PWD -- or the directory where test.txt is saved -- is a good 
starting point (npi): something along the lines of bin/deprecated or 
../man1 .


I know one of the trip-ups I often have if I spend any time away from a 
L/Unix environment has to do with the mv command: I often forget that 
it prefers absolute paths from root folders (or in the case of Cygwin, 
virtual ones taken as real) or dot-dot-slash relative path syntax to 
just /god-directory/ or what-have-you. Many other commands, 
particularly ls and ln -s, are likewise particular about their paths.


Steve W.


--
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



Re: use the list of files stored in a text file and process it

2010-09-30 Thread Larry Hall (Cygwin)

On 9/30/2010 9:37 AM, SJ Wright wrote:

I know one of the trip-ups I often have if I spend any time away from a
L/Unix environment has to do with the mv command: I often forget that it
prefers absolute paths from root folders (or in the case of Cygwin, virtual
ones taken as real) or dot-dot-slash relative path syntax to just
/god-directory/ or what-have-you. Many other commands, particularly ls and
ln -s, are likewise particular about their paths.


That's a sweeping statement without any supporting data.  I guess all I
can say is that my experience doesn't coincide with your statements.

--
Larry Hall  http://www.rfk.com
RFK Partners, Inc.  (508) 893-9779 - RFK Office
216 Dalton Rd.  (508) 893-9889 - FAX
Holliston, MA 01746

_

A: Yes.

Q: Are you sure?

A: Because it reverses the logical flow of conversation.

Q: Why is top posting annoying in email?


--
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



Re: use the list of files stored in a text file and process it

2010-09-30 Thread Brian Wilson

 I store a list of files in a text file (test.txt) on Windows XP.
 I want to use the list of files and process it (e.g. ls).
 What is the command to do that?
 I tried the following commands but to no avail.
 
 $ cat test.txt
 test.txt
 
 $ cat test.txt | xargs ls
 : No such file or directory
 
snip...

Try something like cat test.txt | xargs -i ls {} or cat test.txt | xargs -t 
ls I suspect the first one will work for you and the second one will show you 
the command line before running the command (to help you debug in future).

Sincerely,

Brian S. Wilson


--
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



use the list of files stored in a text file and process it

2010-09-29 Thread albert kao
I store a list of files in a text file (test.txt) on Windows XP.
I want to use the list of files and process it (e.g. ls).
What is the command to do that?
I tried the following commands but to no avail.

$ cat test.txt
test.txt

$ cat test.txt | xargs ls
: No such file or directory

$ cat test.txt | xargs -delimiter=\n ls
xargs: Invalid input delimiter specification elimiter=\n: the delimiter must be 
either a single char
acter or an escape sequence starting with \.

$ cat test.txt | xargs -delimiter='\n' ls
xargs: Invalid input delimiter specification elimiter=\n: the delimiter must be 
either a single char
acter or an escape sequence starting with \.

$ cat test.txt | xargs -delimiter='\\n' ls
xargs: Invalid input delimiter specification elimiter=\\n: the delimiter must 
be 
either a single cha
racter or an escape sequence starting with \.

$ cat test.txt | xargs -delimiter=\\n ls
xargs: Invalid input delimiter specification elimiter=\n: the delimiter must be 
either a single char
acter or an escape sequence starting with \.

$ uname -srv
CYGWIN_NT-5.1 1.7.5(0.225/5/3) 2010-04-12 19:07



--
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



Re: use the list of files stored in a text file and process it

2010-09-29 Thread Christopher Faylor
On Wed, Sep 29, 2010 at 03:39:10PM +, albert kao wrote:
I store a list of files in a text file (test.txt) on Windows XP.
I want to use the list of files and process it (e.g. ls).
What is the command to do that?
I tried the following commands but to no avail.

$ cat test.txt
test.txt

$ cat test.txt | xargs ls
: No such file or directory

It looks like you have CRLF line endings in the file.  Run test.txt
through d2u and the above command should work.  It looks like you
can't just use xargs --delimiter since that option takes only a
single character.

So:

d2u  test.txt | xargs ls

cgf

--
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



Re: use the list of files stored in a text file and process it

2010-09-29 Thread Jeremy Ramer
On Wed, Sep 29, 2010 at 9:39 AM, albert kao wrote:
 I store a list of files in a text file (test.txt) on Windows XP.
 I want to use the list of files and process it (e.g. ls).
 What is the command to do that?
 I tried the following commands but to no avail.

 $ cat test.txt
 test.txt

 $ cat test.txt | xargs ls
 : No such file or directory

 $ cat test.txt | xargs -delimiter=\n ls
 xargs: Invalid input delimiter specification elimiter=\n: the delimiter must 
 be
 either a single char
 acter or an escape sequence starting with \.

 $ cat test.txt | xargs -delimiter='\n' ls
 xargs: Invalid input delimiter specification elimiter=\n: the delimiter must 
 be
 either a single char
 acter or an escape sequence starting with \.

 $ cat test.txt | xargs -delimiter='\\n' ls
 xargs: Invalid input delimiter specification elimiter=\\n: the delimiter must 
 be
 either a single cha
 racter or an escape sequence starting with \.

 $ cat test.txt | xargs -delimiter=\\n ls
 xargs: Invalid input delimiter specification elimiter=\n: the delimiter must 
 be
 either a single char
 acter or an escape sequence starting with \.

 $ uname -srv
 CYGWIN_NT-5.1 1.7.5(0.225/5/3) 2010-04-12 19:07



 --
 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



$ ls $(cat test.txt)

--
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