bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#8796: I need help piping csplit


From: Eric Blake
Subject: bug#8796: I need help piping csplit
Date: Fri, 03 Jun 2011 15:44:04 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110428 Fedora/3.1.10-1.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.10

tag 8796 notabug
close 8796
thanks

On 06/03/2011 01:46 PM, Julio Cesar Gonzalez Torres wrote:
> Hi I have an issue, I'm trying to split several files into two the first one
> is the head of file and the next one has to start with some title, but
> csplit don't allowe me to piping, this is how i'm doing
> 
> $> find ./ -name '*out' | xargs csplit '/All Frequencies/' '/Statistical/'
> 
> I have to now all the locations of files that ends with "out", next every
> time the command finds a file I want to csplited but terminal sends me an
> error:
> 
> csplit: cannot be open «/Statistical/» to read: file or extension don't
> exist--

Thanks for the report.  However, this is not a bug in coreutils, but in
your usage of xargs.  So I'm marking it closed.

It helps to insert 'echo' prior to 'csplit' to see what you are calling:

csplit '/All Frequencies/' '/Statistical/' file1out file2out ...out

But csplit is documented as requiring a single file name, followed by
multiple patterns.

What you WANT to do is:

find . -name '*out' | \
  xargs -I{} csplit {} '/All Frequencies/' '/Statistical'/

The use of -I{} forces xargs to use one file per csplit invocation
(instead of cramming in as many files as possible), as well as to let
you choose where to substitute the file name 9rather than cramming it on
as the last argument).

-- 
Eric Blake   address@hidden    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]