Sponsored Content
Top Forums Shell Programming and Scripting awk 3 files to one based on multiple columns Post 302269088 by Smiling Dragon on Tuesday 16th of December 2008 09:41:22 PM
Old 12-16-2008
Code:
#!/bin/sh
FILE1="gravity.txt"
FILE2="navigation.txt"
FILE3="depth.txt"

while read line1
do
  key=`echo $line1 | cut -d ' ' -f 1-5`
  line2=`grep "$key" $FILE2 | head -1 | cut -d ' ' -f 8-9`
  line3=`grep "$key" $FILE3 | head -1 | cut -d ' ' -f 9`
  echo "$line1 $line2 $line3"
done < $FILE1

(Untested)

Last edited by Smiling Dragon; 12-16-2008 at 10:49 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sorting based on Multiple columns

Hi, I have a requirement whereby I have to sort a flat file based on Multiple Columns (similar to ORDER BY Clause of Oracle). I am getting 10 columns in the flat file and I want the file to be sorted on 1st, 3rd, 4th, 7th and 9th columns in ascending order. The flat file is pipe seperated. Any... (15 Replies)
Discussion started by: dharmesht
15 Replies

2. Shell Programming and Scripting

sort by based on multiple columns

Hi, Is there any way to sort a file in cshell by sort command, sorting it by multiple fields, like to sort it first by the second column and then by the first column. Thanks forhead (1 Reply)
Discussion started by: Takeeshe
1 Replies

3. UNIX for Dummies Questions & Answers

Extracting columns from multiple files with awk

hi everyone! I already posted it in scripts, I'm sorry, it's doubled I'd like to extract a single column from 5 different files and put them together in an output file. I saw a similar question for 2 input files, and the line of code workd very well, the code is: awk 'NR==FNR{a=$2; next}... (1 Reply)
Discussion started by: orcaja
1 Replies

4. Shell Programming and Scripting

Extracting columns from multiple files with awk

hi everyone! I'd like to extract a single column from 5 different files and put them together in an output file. I saw a similar question for 2 input files, and the line of code workd very well, the code is: awk 'NR==FNR{a=$2; next} {print a, $2}' file1 file2 I added the file3, file4 and... (10 Replies)
Discussion started by: orcaja
10 Replies

5. Shell Programming and Scripting

awk script to split file into multiple files based on many columns

So I have a space delimited file that I'd like to split into multiple files based on multiple column values. This is what my data looks like 1bc9A02 1 10 1000 FTDLNLVQALRQFLWSFRLPGEAQKIDRMMEAFAQRYCQCNNGVFQSTDTCYVLSFAIIMLNTSLHNPNVKDKPTVERFIAMNRGINDGGDLPEELLRNLYESIKNEPFKIPELEHHHHHH 1ku1A02 1 10... (9 Replies)
Discussion started by: viored
9 Replies

6. Shell Programming and Scripting

Match files based on either of the two columns awk

Dear Shell experts, I have 2 files with structure: File 1: ID and count head test_GI_count1.txt 1000094 2 10039307 1 10039641 1 10047177 11 10047359 1 1008555 2 10120302 1 10120672 13 10121776 1 10121865 32 And 2nd file: head Protein_gi_GeneID_symbol.txt protein_gi GeneID... (11 Replies)
Discussion started by: smitra
11 Replies

7. Shell Programming and Scripting

awk arrays comparing multiple columns across two files.

Hi, I'm trying to use awk arrays to compare values across two files based on multiple columns. I've attempted to load file 2 into an array and compare with values in file 1, but success has been absent. If anyone has any suggestions (and I'm not even sure if my script so far is on the right lines)... (4 Replies)
Discussion started by: hubleo
4 Replies

8. Shell Programming and Scripting

awk Parse And Create Multiple Files Based on Field Value

Hello: I am working parsing a large input file which will be broken down into multiples based on the second field in the file, in this case: STORE. The idea is to create each file with the corresponding store number, for example: Report_$STORENUM_$DATETIMESTAMP , and obtaining the... (7 Replies)
Discussion started by: ec012
7 Replies

9. Shell Programming and Scripting

Appending different columns of multiple files in awk

Hello All, I have three input files cat file1 col1|col2|col3 a|1|A b|2|B cat file2 col1|col2|col3 c|3|C cat file3 col1|col2|col3 d|4|D e|5|E i want below output file4 col1|col2 a|1 (6 Replies)
Discussion started by: looney
6 Replies

10. Shell Programming and Scripting

Paste columns based on common column: multiple files

Hi all, I've multiple files. In this case 5. Space separated columns. Each file has 12 columns. Each file has 300-400K lines. I want to get the output such that if a value in column 2 is present in all the files then get all the columns of that value and print it side by side. Desired output... (15 Replies)
Discussion started by: genome
15 Replies
cam(1)							      General Commands Manual							    cam(1)

NAME
cam - CPU'S AUDIO MIXER for Linux SYNOPSIS
cam [-v x,y] [--volume x,y] [-b x,y] [--bass x,y] [-t x,y] [--treble x,y] [-s x,y] [--synth x,y] [-p x,y] [--pcm x,y] [-S x,y] [--speaker x,y] [-l x,y] [--line x,y] [-m x,y] [--mic x,y] [-c x,y] [--cd x,y] [-M x,y] [--mixer x,y] [-a x,y] [--altpcm x,y] [-r x,y] [--reclev x,y] [-i x,y] [--igain x,y] [-o x,y] [--ogain x,y] [-l1 x,y] [--line1 x,y] [-l2 x,y] [--line2 x,y] [-l3 x,y] [--line3 x,y] [-3d 1|0] [--3dse 1|0] [-agc 1|0] [--agc 1|0] [-h] [-?] [--help] [-get] [-save] [-getfile filename] [-savefile filename] xcam DESCRIPTION
This is an audio mixer for Linux. You have the choice to use it with an interface or at the command line. OPTIONS
When using the interface you can use the following keys : LEFT ARROW decrease the volume of the current device. RIGHT ARROW increase the volume of the current device. UP ARROW go to previous device. DOWN ARROW go to next device. L locks or unlocks : unlocked : you can control the left and right channel separately. lock : left and right channel are controlled together. R turn on/off recording mode : red lamp : recording turned on green lamp : recording turned off 3 turn on/off 3D Stereo Enhancement (3DSE) device : when turned on green indicator 3D will be lit at the left side of main volume handle. A turn on/off microphone Automatic Gain Control : when turned on green indicator AGC will be lit at the left side of microphone volume handle. S save the settings of ALL devices in a file ($HOME/.camrc) G loads the saved settings and restores them. H shows the help screen. Q/ESC exits the program and returns to shell. NOTE: you can use upper or lower case. When using the command line options the interface is not shown. The following options are available : -v, --volume x,y Set 'volume' to x (left) and y (right) -b, --bass x,y Set 'bass' to x (left) and y (right) -t, --trebble x,y Set 'treble' to x (left) and y (right) -s, --synth x,y Set 'synth' to x (left) and y (right) -p, --pcm x,y Set 'pcm' to x (left) and y (right) -S, --speaker x,y Set 'speaker' to x (left) and y (right) -l, --line x,y Set 'line in' to x (left) and y (right) -m, --mic x,y Set 'microphone' to x (left) and y (right) -c, --cd x,y Set 'CD in' to x (left) and y (right) -I, --imix x,y Set 'mixer' to x (left) and y (right) -a, --altpcm x,y Set 'altpcm' to x (left) and y (right) -r, --reclev x,y Set 'record level' to x (left) and y (right) -i, --igain x,y Set 'input gain' to x (left) and y (right) -o, --ogain x,y Set 'output gain' to x (left) and y (right) -l1, --line1 x,y Set 'line 1' to x (left) and y (right) -l2, --line2 x,y Set 'line 2' to x (left) and y (right) -l3, --line3 x,y Set 'line 3' to x (left) and y (right) -3d, --3dse 1|0 Set 3D Stereo Enhancement to 1 (on) or 0 (off) -agc, --agc 1|0 Set Automatic Gain Control for microphone to 1 (on) or 0 (off) -get restore the saved values from $HOME/.camrc -save save the values to $HOME/.camrc -getfile filename restore the saved values from file 'filename' -savefile filename save the values to file 'filename' -h, -?, --help displays help NOTE: x and y are in range from 1 to 100. Higher or lower numbers are ignored. BUGS
None known as yet. If you find one, please let me know. AUTHOR
Jan 'TWP' VANDENBERGHE <jvdbergh@uia.ua.ac.be> cam(1)
All times are GMT -4. The time now is 05:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy