https://github.com/tomnomnom/comb
Combine the lines from two files in every combination
https://github.com/tomnomnom/comb
Last synced: about 2 months ago
JSON representation
Combine the lines from two files in every combination
- Host: GitHub
- URL: https://github.com/tomnomnom/comb
- Owner: tomnomnom
- Created: 2018-02-18T13:24:27.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-02-18T17:49:46.000Z (about 7 years ago)
- Last Synced: 2025-03-18T07:50:40.209Z (about 2 months ago)
- Language: Go
- Size: 2.93 KB
- Stars: 50
- Watchers: 5
- Forks: 16
- Open Issues: 0
-
Metadata Files:
- Readme: README.mkd
Awesome Lists containing this project
README
# comb
Combine the lines from two files in every combination. Apparently that's
called the cartesian product but don't quote me on that.## Install
```
▶ go get -u github.com/tomnomnom/comb
```Or [download a binary](https://github.com/tomnomnom/comb/releases) and put
it somewhere in your `$PATH` (e.g. `/usr/bin/comb`).## Usage
```
▶ comb -h
Combine the lines from two files in every combinationUsage:
comb [OPTIONS]Options:
-f, --flip Flip mode (order by suffix)
-s, --separator String to place between prefix and suffix
```## Example
Normal mode:
```
▶ cat prefixes
1
2▶ cat suffixes
A
B
C▶ comb prefixes suffixes
1A
1B
1C
2A
2B
2C
```Flip mode (order by suffix):
```
▶ comb --flip prefixes suffixes
1A
2A
1B
2B
1C
2C
```Separator:
```
▶ comb --separator="-" prefixes suffixes
1-A
1-B
1-C
2-A
2-B
2-C
```## Can't you just do this with a couple of nested bash loops?
Yes, but it's a PITA to type this:
```
▶ while read prefix; do while read suffix; do echo $prefix$suffix; done < suffixes; done < prefixes
1A
1B
1C
2A
2B
2C
```