Join command in Bash


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

>Solution :

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 

Leave a Reply Cancel reply