Code Monkey home page Code Monkey logo

file-merge-script's Introduction

File Merge Script

A simple and fast bash script for GNU systems to merge multiple files in a directory to a single file. This can come in handy if you need to merge multiple CSV files to a single csv file or multiple TEXT files to a single text file.

How to Run

Suppose you have a set of txt files in a directory called ~/myfiles

~/
 └─── myfiles
     │   test1.txt
     │   test2.txt
     │   test3.txt
     │   test4.txt
     │   other.txt
     └─── ...

To merge all files with name starting test to a output file called result.txt

Command

/bin/bash file-merge-script.sh -d ~/myfiles -p 'test' -o 'result.txt'

Options

  • -d : (required) directory containing files
  • -p : (optional) input file prefix | default - all files in the given directory
  • -o : (optional) output file name | default - 'output.txt'
  • -s : (optional) line to start from matching files | default - 1
  • -f : (optional) line to start from first matching file | default - 1
  • -r : (optional) delete prefix files after output file created
  • -l : (optional) log prefix

Scenarios

Merge CSV Files

  • Merge multiple csv files with headers from the 1st file and ignore headers from the rest of the files
/bin/bash file-merge-script.sh -d ~/myfiles -p 'test' -o 'result.csv' -f 1 -s 2

In above command -f 1 gets all content (from line 1) of first matching csv file and -s 2 gets all matching file contents from line 2.

file-merge-script's People

Contributors

prabushitha avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

dineshkumardg

file-merge-script's Issues

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.