Sponsored Content
Full Discussion: [bash] join command
Top Forums Shell Programming and Scripting [bash] join command Post 302344655 by Dedalus on Monday 17th of August 2009 08:40:35 AM
Old 08-17-2009
[bash] join command

Hi

I've 2 files:
Quote:
file 1:
4 3.855143e-07 3.855143e-07
6 1.927572e-07 5.782715e-07
7 3.855143e-07 9.637858e-07
8 1.927572e-07 1.156543e-06
30 4.018987e-05 8.086162e-05

file 2:
1 2.918198e-03 2.918198e-03
2 2.205868e-02 2.497688e-02
3 2.396582e-03 2.737346e-02
4 9.962099e-07 2.737445e-02
7 9.962099e-08 2.737455e-02
30 1.195452e-06 2.737575e-02
31 4.114347e-05 2.741689e-02
I'd like to get an output like:
Quote:
file output:

4 3.855143e-07 3.855143e-07 9.962099e-07 2.737445e-02
7 3.855143e-07 9.637858e-07 9.962099e-08 2.737455e-02
30 4.018987e-05 8.086162e-05 1.195452e-06 2.737575e-02
if I do like:

Code:
join file1 file2

I get
Quote:
4 3.855143e-07 3.855143e-07 9.962099e-07 2.737445e-02
7 3.855143e-07 9.637858e-07 9.962099e-08 2.737455e-02
Where line 30 miss. I'm reading this old post:
https://www.unix.com/unix-dummies-que...n-command.html.
Where a solutionn with awk is suggested.
I mean is possible get the same result with join command?

Thanks

D.

P.S. if file1 looks like:
Quote:
4 3.855143e-07 3.855143e-07
6 1.927572e-07 5.782715e-07
7 3.855143e-07 9.637858e-07
30 4.018987e-05 8.086162e-05
the join command work correctly.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

join (pls help on join command)

Hi, I am a new learner of join command. Some result really make me confused. Please kindly help me. input: file1: LEO oracle engineer 210375 P.Jones Office Runner ID897 L.Clip Personl Chief ID982 S.Round UNIX admin ID6 file2: Dept2C ID897 6 years Dept5Z ID982 1 year Dept3S ID6 2... (1 Reply)
Discussion started by: summer_cherry
1 Replies

2. Shell Programming and Scripting

awk command for simple join command but based on 2 columns

input1 a_a a/a 10 100 a1 a_a 20 200 b1 b_b 30 300 input2 a_a a/a xxx yyy a1 a1 lll ppp b1 b_b kkk ooo output a_a a/a 10 100 xxx yyy (2 Replies)
Discussion started by: ruby_sgp
2 Replies

3. Shell Programming and Scripting

Bash join script not working

So i'm currently working on a project where I'm attempting to display information of users from the /etc/passwd file and also another information file holding addition information about users. Problem is I've been trying to join the two files together and have all of the information about each... (2 Replies)
Discussion started by: Nostyx
2 Replies

4. UNIX for Dummies Questions & Answers

how to join two files using "Join" command with one common field in this problem?

file1: Toronto:12439755:1076359:July 1, 1867:6 Quebec City:7560592:1542056:July 1, 1867:5 Halifax:938134:55284:July 1, 1867:4 Fredericton:751400:72908:July 1, 1867:3 Winnipeg:1170300:647797:July 15, 1870:7 Victoria:4168123:944735:July 20, 1871:10 Charlottetown:137900:5660:July 1, 1873:2... (2 Replies)
Discussion started by: mindfreak
2 Replies

5. UNIX for Dummies Questions & Answers

How to use the the join command to join multiple files by a common column

Hi, I have 20 tab delimited text files that have a common column (column 1). The files are named GSM1.txt through GSM20.txt. Each file has 3 columns (2 other columns in addition to the first common column). I want to write a script to join the files by the first common column so that in the... (5 Replies)
Discussion started by: evelibertine
5 Replies

6. UNIX for Dummies Questions & Answers

Join Command

Hi, Please explain the working process of join command. File 1 P B S A C AFile2 C B P A S DBut the output of join command is... join File1.txt File2.txt P B A S A DBut I guess the output should be P B A S A D C A BPlease correct me,if i am worong or missing some thing. Thanks (2 Replies)
Discussion started by: satyar
2 Replies

7. Shell Programming and Scripting

Bash: join 2 files

Hello ! I want to join 2 files. They look like this: KE340296.1 1 0/0:11 KE340296.1 2 0/0:12 KE340296.1 6 0/1:13 KE340297.1 1 0/1:14 KE340297.1 3 0/1:15 KE340297.1 4 0/1:16 and KE340296.1 1 0/0:21 KE340296.1 2 0/0:22 KE340296.1 3... (4 Replies)
Discussion started by: MumuGB
4 Replies

8. Shell Programming and Scripting

How to join 2 text files using bash scripting?

Hi Guys, I want to combine 2 files and and put together in 1 file . See below desired output. Any help will be much appreciated. FILE AX 2134 101L 12345.00 22222.00 1 10 X 2134 101L 12345.00 22222.00 11 20 X 2134 101L 12345.00 22222.00 21 30 X 2134 111L 77777.00 ... (3 Replies)
Discussion started by: H.R
3 Replies

9. UNIX for Beginners Questions & Answers

BASH join command error PLS

i've tried every variation possible and keep getting not sorted error. can anyone shed any light on how to do this? (image attached) (1 Reply)
Discussion started by: deadcick
1 Replies

10. Shell Programming and Scripting

Join columns across multiple lines in a Text based on common column using BASH

Hello, I have a file with 2 columns ( tableName , ColumnName) delimited by a Pipe like below . File is sorted by ColumnName. Table1|Column1 Table2|Column1 Table5|Column1 Table3|Column2 Table2|Column2 Table4|Column3 Table2|Column3 Table2|Column4 Table5|Column4 Table2|Column5 From... (6 Replies)
Discussion started by: nv186000
6 Replies
SHELL-QUOTE(1p) 					User Contributed Perl Documentation					   SHELL-QUOTE(1p)

NAME
shell-quote - quote arguments for safe use, unmodified in a shell command SYNOPSIS
shell-quote [switch]... arg... DESCRIPTION
shell-quote lets you pass arbitrary strings through the shell so that they won't be changed by the shell. This lets you process commands or files with embedded white space or shell globbing characters safely. Here are a few examples. EXAMPLES
ssh preserving args When running a remote command with ssh, ssh doesn't preserve the separate arguments it receives. It just joins them with spaces and passes them to "$SHELL -c". This doesn't work as intended: ssh host touch 'hi there' # fails It creates 2 files, hi and there. Instead, do this: cmd=`shell-quote touch 'hi there'` ssh host "$cmd" This gives you just 1 file, hi there. process find output It's not ordinarily possible to process an arbitrary list of files output by find with a shell script. Anything you put in $IFS to split up the output could legitimately be in a file's name. Here's how you can do it using shell-quote: eval set -- `find -type f -print0 | xargs -0 shell-quote --` debug shell scripts shell-quote is better than echo for debugging shell scripts. debug() { [ -z "$debug" ] || shell-quote "debug:" "$@" } With echo you can't tell the difference between "debug 'foo bar'" and "debug foo bar", but with shell-quote you can. save a command for later shell-quote can be used to build up a shell command to run later. Say you want the user to be able to give you switches for a command you're going to run. If you don't want the switches to be re-evaluated by the shell (which is usually a good idea, else there are things the user can't pass through), you can do something like this: user_switches= while [ $# != 0 ] do case x$1 in x--pass-through) [ $# -gt 1 ] || die "need an argument for $1" user_switches="$user_switches "`shell-quote -- "$2"` shift;; # process other switches esac shift done # later eval "shell-quote some-command $user_switches my args" OPTIONS
--debug Turn debugging on. --help Show the usage message and die. --version Show the version number and exit. AVAILABILITY
The code is licensed under the GNU GPL. Check http://www.argon.org/~roderick/ or CPAN for updated versions. AUTHOR
Roderick Schertler <roderick@argon.org> perl v5.8.4 2005-05-03 SHELL-QUOTE(1p)
All times are GMT -4. The time now is 04:58 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy