Parse input of two files to be the same in awk

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Parse input of two files to be the same in awk
# 1  
Old 01-12-2016
Parse input of two files to be the same in awk

I have two files that I am going to use diff to find the differences but need to parse them before I do that. I have include the format of each file1 and file2 with the desired output of each (the first 5 fields in each file). The first file has a "chr" before the # that needs to be removed. I have included an awk for file2 that I think will work but not sure about file1. Thank you Smilie.

chr1    977330    .    T    C    1442.18    PASS    AF=1;AO=150;DP=150;FAO=151;FDP=151;FR=.;FRO=0;FSAF=86;FSAR=65;FSRF=0;FSRR=0;FWDB=0.0177391;FXX=0;HRUN=1;
FSRR    1/1:68:150:151:0:0:150:151:1:65:85:0:0:65:86:0:0
chr1    981931    .    A    G    773.354    PASS

desired output of file1
1    977330    .    T    C

1    955597    .    G    G    256.13    PASS    AC=0;AN=2;SF=8;GENE=AGRN    
GT:MQRS:FS:DPF:RPRS:QD:BQRS:MQR:AD:GQ:MQ0:VAL:PL:ROI    0/0:.:.:.:.:.:.:.:.:.:.:1:.:1  
  ./.:.:.:.:.:.:.:.:.:.:.:.:.:0    ./.:.:.:.:.:.:.:.:.:.:.:.:.:0    ./.:.:.:.:.:.:.:.:.:.:.:.:.:0    ./.:.:.:.:.:.:.:.:.:.:.:.:.:0    ./.:.:.:.:.:.:.:.:.:.:.:.:.:0  
  ./.:.:.:.:.:.:.:.:.:.:.:.:.:0    ./.:.:.:.:.:.:.:.:.:.:.:.:.:0    0/0:0.252:0.000:94:-0.100:8.83:1.930:59.78:38,0:99:0:1:985,985,985:1  
  ./.:.:.:.:.:.:.:.:.:.:.:.:.:0    ./.:.:.:.:.:.:.:.:.:.:.:.:.:0    ./.:.:.:.:.:.:.:.:.:.:.:.:.:0    ./.:.:.:.:.:.:.:.:.:.:.:.:.:0    ./.:.:.:.:.:.:.:.:.:.:.:.:.:0    ./.:.:.:.:.:.:.:.:.:.:.:.:.:0  
  ./.:.:.:.:.:.:.:.:.:.:.:.:.:0    ./.:.:.:.:.:.:.:.:.:.:.:.:.:0    ./.:.:.:.:.:.:.:.:.:.:.:.:.:0    ./.:.:.:.:.:.:.:.:.:.:.:.:.:0    ./.:.:.:.:.:.:.:.:.:.:.:.:.:0    ./.:.:.:.:.:.:.:.:.:.:.:.:.:0  
  ./.:.:.:.:.:.:.:.:.:.:.:.:.:0    ./.:.:.:.:.:.:.:.:.:.:.:.:.:0    ./.:.:.:.:.:.:.:.:.:.:.:.:.:0    ./.:.:.:.:.:.:.:.:.:.:.:.:.:0    ./.:.:.:.:.:.:.:.:.:.:.:.:.:0    0/0:.:.:.:.:.:.:.:.:.:.:1:.:1 
   ./.:.:.:.:.:.:.:.:.:.:.:.:.:0    ./.:.:.:.:.:.:.:.:.:.:.:.:.:0    ./.:.:.:.:.:.:.:.:.:.:.:.:.:0    ./.:.:.:.:.:.:.:.:.:.:.:.:.:0    0/0:.:.:.:.:.:.:.:.:.:.:1:.:1

desired output of file2
1    955597    .    G    G

awk '{print $1}' file1
awk '{print $1}' file1
awk '{print $1}' file1
awk '{print$1, $2, $3, $4, $5}' file2

Last edited by cmccabe; 01-12-2016 at 04:29 PM.. Reason: fixed format
# 2  
Old 01-12-2016
awk '{sub (/chr/, "", $1); print$1, $2, $3, $4, $5}' file1

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. 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

2. Shell Programming and Scripting

awk to parse huge files

Hello All, I have a situation as below: (1) Read a source file (a single file of 1.2 million rows in it ) (2) Read Destination files one by one and replace the content ( few fields in it ) with the corresponding matching field from source file. I tried as below: ( please note I am not... (4 Replies)
Discussion started by: panyam
4 Replies

3. Shell Programming and Scripting

Parse input -AWK

Input File Defined configuration: cfg: CLL_DCC_Fabric_A BTS00P21; BAU_AP00P01QC; BAU_LGSCNJP02; BAU_TS00P20; BAU_DSMSM14; BAU_HT00P02; BAU_DSMSM13; BAU_HT00P01; cfg: CX0014_list BAU_TS00P20; BAU_NYP_PRODIAD1_CJ;... (5 Replies)
Discussion started by: greycells
5 Replies

4. Shell Programming and Scripting

Help with reading two input files in awk

Hello, I'm trying to write an awk program that reads two files inputs. example, file 1: 0.00017835 0.000176738 0.00018811 0.000189504 0.000188155 0.000180065 0.000178991 0.000178252 0.000182513 file 2: 1.7871769E-05 1.5139576E-16 1.5140196E-16 1.5139874E-16 1.7827407E-04 ... (5 Replies)
Discussion started by: joseamck
5 Replies

5. Shell Programming and Scripting

AWK failing to parse on certain files

Dear Unix Gurus, need your expertise to help troubleshoot a certain problem i'm having. I crated a shell script which will ftp get 1 crash log from multiple servers (listed in a text file). Each log will then be parsed by calling an awk script. The problem is, for certain log its parsing... (7 Replies)
Discussion started by: tarj
7 Replies

6. Shell Programming and Scripting

awk script to parse results from TWO files

I am trying to parse two files and get data that does not match in one of the columns ( column 3 in my case ) Data for two files are as follows A.txt ===== abc 10 5 0 1 16 xyz 16 1 1 0 18 efg 30 8 0 2 40 ijk 22 2 0 1 25 B.txt ===== abc... (6 Replies)
Discussion started by: roger67
6 Replies

7. Shell Programming and Scripting

AWK using two input files

Hi , i have two input files one is input.gz and another is ( input.txt) text gz format input file each record contains 10 fields and corresponding header value is present in the text file as a single record i.e text file contains only 10 records which is header value,so output of the awk... (1 Reply)
Discussion started by: Ajoy
1 Replies

8. Shell Programming and Scripting

Comparing 2 input files -Awk

Compare 2 files and print the values input1 (c1 20 100 X_y10) along with one closest highest (c1 100 200 X_y10) and one lowest values (c1 10 15 X_y10) from input2 input1 c1 20 100 X_y10 input2 c1 5 10 X_y10 c1 10 15 X_y10 c1 100 200 X_y10 c1 200 300 X_y10 output ... (8 Replies)
Discussion started by: bumblebee_2010
8 Replies

9. Shell Programming and Scripting

Splitting input files into multiple files through AWK command

Hi, I needs to split *.txt files from single directory depends on the some mutltiple input values. i have wrote the code like below for file in *.txt do grep -i -h "value1|value2" $file > $file; done. My requirment is more input values needs to be given in grep; let us say 50... (3 Replies)
Discussion started by: arund_01
3 Replies

10. Shell Programming and Scripting

2 input files for awk

Hi, i have 2 files like f1 and f2 f1: 1 Note: some times it will be cahnged to 2 and 3. f2: 1:20 2:30 4:50 6:70 8:90 3:20 1:30 1:40 output: 1:80 (sum of 1) (6 Replies)
Discussion started by: koti_rama
6 Replies
Login or Register to Ask a Question

Featured Tech Videos