0

I'm running Centos 5.3, and I'm using split as a critical part of a data import. The version of split running on the servers doesn't seem to support -p (pattern matching).

The version on the server is split (GNU coreutils) 5.97, while the version on my mac, which has -p, doesn't respond to either -v or --version.

yum list split doesn't mention anything. How can I get -p on there?

  • Update: There's a csplit command, but it's 10x as slow – Sean Clark Hess Mar 6 '10 at 21:15
  • I ended up writing my own custom thing in node.js - it's as fast as split, and 5x as fast as csplit. dang. – Sean Clark Hess Mar 6 '10 at 21:16
1

The short version is that you're looking at the GNU version of split on Linux, and the BSD version on your Mac.

My guess is that you could download the source for the BSD version and compile it on your Linux host - but I've never tried such an operation. Also, if you did such - upgrading the GNU coreutils might break it in the future.

http://plug-and-pray.blogspot.com/2009/11/how-to-split-large-files-in-linux-and.html

| improve this answer | |
  • 1
    I would also add that updating coreutils will also update many more commands other than split. You will be familiar with many of these; to see just what's affected, do rpm -q --filesbypkg coreutils. Many of these commands aren't going to break by being at another version, but put them into a pipeline, and there's the possibility for deprecated options, or options being changed, etc. I would create a new system(virtual or physical) configured like the existing system is now and upgrade coreutils there as a testbed. Test the testbed throughly, then upgrade coreutils on the existing system. – Kevin M Mar 6 '10 at 16:22
0

My guess is to try compiling a newer version of coreutils on CentOS, then copy split into a special directory, perhaps the same directory as your script). Be careful of the default PATH though, this should not be in in any of the system paths. You may want to rename split to somethine else too, say newsplit.

Your script will then need to be modified to use this version of split (newsplit). This can be done in many ways, such as changing the PATH variable in your script, or using the full path of split/newsplit. I normally do this in the bash shell:

#!/bin/bash
_CAT="/usr/bin/echo"
_SPLIT="${PWD}/newsplit"

${_CAT} filename.txt | ${_SPLIT}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.