Giter VIP home page Giter VIP logo

quote-and-join's Introduction

https://github.com/jfgiraud/quote-and-join/actions

Description

Small utilities to:

  • quote and join words or lines in files

  • split and unquote words in files

Installation

The destination directory will contain 3 sub-directories: bin, share and man.

Using git repo.

$ git clone https://github.com/jfgiraud/quote-and-join.git
$ cd quote-and-join
$ sudo make install DESTDIR=/usr/local

Using latest tarball release.

$ curl -s -L https://api.github.com/repos/jfgiraud/quote-and-join/releases/latest | grep browser_download_url | cut -d':' -f2- | tr -d ' ",' | xargs wget -O quote-and-join.tgz
$ sudo tar zxvf quote-and-join.tgz -C /usr/local

Usages

Use man.

$ man qaj
$ man uqaj

Use option.

$ qaj -h
$ uqaj -h

Examples qaj

Quote words with ' and join with ,.

$ echo lorem ipsum dolores est | qaj -w -q -j,
'lorem','ipsum','dolores','est'

Quote words with " and join with ,ย  (comma + space).

$ echo lorem ipsum dolores est | qaj -w -qq -j', '
"lorem", "ipsum", "dolores", "est"

Prefix words with <, suffix words with > and join with #.

$ echo lorem ipsum dolores est | qaj -w -a'<' -b'>' -j#
<lorem>#<ipsum>#<dolores>#<est>

Extract words.

$ echo lorem ipsum dolores est | qaj -w
lorem
ipsum
dolores
est

Prefix words with <, suffix words with the associated parenthese > and join with #.

$ echo lorem ipsum dolores est | qaj -w -p'<' -j#
<lorem>#<ipsum>#<dolores>#<est>

Quote lines with " and join with ,. Lines are trimmed..

$ printf "lorem\nipsum\n dolores\n\nest" | qaj -qq -j,
"lorem","ipsum","dolores","est"

Quote lines with " and join with ,. Lines are not trimmed..

$ printf "lorem\nipsum\n dolores\n\nest" | qaj -qq -J -t
"lorem", "ipsum", " dolores", "est"

Quote lines with " and join with ,. Lines are trimmed. Add a prefix and suffix on the final result..

$ printf "lorem\nipsum\n dolores\n\nest" | qaj -qq -j, -A 'Final result: ' -B '.'
Final result: "lorem","ipsum","dolores","est".

Examples uqaj

Remove prefix before, remove suffix after, split using ,, unquote using {}.

$ s="before{first item},{second  item},{third item}after"
$ echo $s | uqaj -j, -p'{' -A before -B after
first item
second item
third item

Remove prefix <, remove suffix >, split using ,, unquote using ".

$ s='<"lorem", "ipsum", "dolores", "est">'
$ echo $s | uqaj -J -A '<' -B '>' -qq
lorem
ipsum
dolores
est

Remove prefix <, remove suffix >, split using ,, unquote using ".

$ s=$'<"lorem",\n"ipsum", "dolores",\n"est">'
$ echo $s | uqaj -J -A '<' -B '>' -qq
lorem
ipsum
dolores
est

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.