Home > Back-end >  Join command in Bash
Join command in Bash

Time:01-15

I community. I've got a problem with bash terminal. There are two files that I need to merge and I want to use delimiter ; in join command, but it doesn't work. How can I fix it? Thanks!

join -1 2 -2 2 -t; tasks.txt procowner.txt > answ.txt 

upd. bash message

join: option requires an argument -- t
usage: join [-a fileno | -v fileno ] [-e string] [-1 field] [-2 field]
            [-o list] [-t char] file1 file2
zsh: command not found: tasks.txt

CodePudding user response:

The ; is treated as a command terminator by bash. This in turn means bash sees two separate commands:

join -1 2 -2 2 -t

# and

tasks.txt procowner.txt > answ.txt 

The first one generates a syntax error for the join command; the second one generates an error stating tasks.txt is not a valid command.

The simple fix is to quote the ;, eg:

join -1 2 -2 2 -t';' tasks.txt procowner.txt > answ.txt 
  • Related