Coder Social home page Coder Social logo

resplit's Introduction

resplit

Scala Steward badge

A command line utility for splitting files based on a regular expression

-- reimplementation of gnu csplit https://man7.org/linux/man-pages/man1/csplit.1.html

Built with ScalaNative, fs2 and cats!

Demo

Streaming "The Adventures of Sherlock Holmes" with wget and spliting by chapter regex into unique files

Resplit_Mov_AdobeExpress

Usage

> resplit --help
Usage: resplit [options] regexToMatch [regexToSub]

Splits a file based on a regex. split files will be prefixed by digits,
and named by the contents of the matched regular expression.

Outputs names of files created to stdout

  regexToMatch             A regular expression to split the file on
  regexToSub               A regular expression substitution expression to use to format the output filenames
  -n, --digits <value>     Number of digits to left-pad the split filenames with
  -d, --directory <value>  Directory to write the split files into
  -f, --file <value>       Read from the specified file instead of stdin
  --suppressMatched        Include the line that matched the regexMatch arg as the first line in the split files
  -s, --quiet              Quiet
  -z, --elide-empty-files  Remove empty output files
  --help                   prints this usage text

Installation

  • Download the latest release for your target platform
    • wget https://github.com/aesakamar/resplit/releases/download/v0.1.1/resplit-macos-latest
  • Grant executable permissions on the downloaded file
    • chmod +x resplit-macos-latest
      
  • Move the executable to a place accessible onyour $PATH
    • mv resplit-macos-latest ~/bin/resplit
      

Examples

Input:


cat1
cat2
cat3
dog1
cat4
cat5
cat6
dog2
cat7
cat8
cat9
> cat testfile | resplit '(dog)\d' '$1'

Output:


000_

cat1
cat2
cat3

001_dog

dog1
cat4
cat5
cat6

002_dog

dog2
cat7
cat8
cat9

resplit's People

Contributors

aesakamar avatar scala-steward-aesakamar[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

gilcu2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.