unix join separator char

前端 未结 6 920
旧时难觅i
旧时难觅i 2020-12-14 01:30

Sorry for the maybe trivial question.

I fought a bit with the unix join command, trying to get tabs instead of whitespaces as the default separators. -t is

相关标签:
6条回答
  • 2020-12-14 01:55

    You can enter tab by pressing CTRL+v Tab

    join -t '<CTRL+v><Tab>' file1 file2
    
    0 讨论(0)
  • 2020-12-14 01:55

    man join says, that the options have to come in front of the filenames. Have you tried

    join -t "\t" file1 file2
    

    ?

    Edit: Reflecting Tonio's answer, the correct line would read

    join -t $'\t' file1 file2
    
    0 讨论(0)
  • 2020-12-14 01:59

    Other way is:

    join -t "`echo -e "\t"`" file1 file2`

    or in a more bash-fashion:

    join -t "$(echo -e "\t")" file1 file

    0 讨论(0)
  • 2020-12-14 02:03

    An alternate trick that seems to work is to enclose the -t option in quotes with the literal tab character. This looks like:

    join '-t    ' ...
    

    with a variable space between the t and the closing quote (since it's a tab).

    Typed, it's:

    join<Spc>'-t<Ctrl-v><Tab>' ...
    
    0 讨论(0)
  • 2020-12-14 02:08
    join -t "`echo '\t'`" file1 file2
    

    ps: on my machine, Red Hat Enterprise Linux Server release 5.1 (Tikanga), the command join -t $'\t' file1 file2 returns "Illegal variable name".

    0 讨论(0)
  • 2020-12-14 02:13

    I think it takes a variable generated on-the-fly

    Try

    join file1 file12 -t $'\t'
    
    0 讨论(0)
提交回复
热议问题