To take unmatch field in first column


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting To take unmatch field in first column
# 1  
Old 08-07-2013
To take unmatch field in first column

Im uising the below command to take the matching pattern on 1st filed

Code:
awk 'NR==FNR{_[$1];next}$4 in _' file1 file2

Code:
file1 
12 sam kash
232 f10 kash
22 data kas
 
file2
56
789
232
 
Needed output:
12 
22


How to get the unmatching pattern
# 2  
Old 08-07-2013
Code:
awk 'NR==FNR{A[$1];next}!($1 in A){print $1}' file2 file1

This User Gave Thanks to Yoda For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Split file based on a column/field value

Hi All, I have a requirement to split file into 2 sets of file. Below is a sample data of the file AU;PTN;24EX;25-AUG-14;AU;123;SE;123;Test NN;;;;ASD; AU;PTN;24EX;25-AUG-14;AU;456;SE;456;Test NN;;;;ASD; AU;PTN;24EX;25-AUG-14;AU;147;SE;147;Test NN;;;;ASD;... (6 Replies)
Discussion started by: galaxy_rocky
6 Replies

2. Shell Programming and Scripting

Get the average from column and write the value at the last field

Dear Experts, Kindly help me please to get the average from column 14 and to write the value at the last field., But we need to take as reference the column 16., example the first 4 lines has the same value in column 16, therefore I want ot get the average only for these lines in column 14. And... (2 Replies)
Discussion started by: jiam912
2 Replies

3. Shell Programming and Scripting

Running two scripts and then compare match or unmatch

Hello ! I need to run two diff script to two different remote server and then compare flies from server3. script1 - server 1 - /xxx/xxx/dir scrpt 2 - server 2 /xxx/xxx/dir script1 already will generate script1.output1 and script2 also will generate script2.output2 Compare: ... (2 Replies)
Discussion started by: amir07
2 Replies

4. Shell Programming and Scripting

print non empty column/field value

I have below file 25-09-2012 24-09-2012 19-09-2012 31-07-2012 30-04-2012 30-03-2012 ASIAEXFVNV N/A CEU 4 DMIRSOA N/A CAS 2 2 2 DMIRSOA N/A MIDMT 2 NFIAL22 N/A HVNY 11 11 11 NFIAL22 N/A NYAL3 11 11 11 NFIAL22 N/A NYCN 11 11 11 ... (4 Replies)
Discussion started by: manas_ranjan
4 Replies

5. Shell Programming and Scripting

Inserting some text if a field in the last column changes

Hi, I have a file which looks like this: A 01 00 B 02 00 C 04 00 D 00 01 E 01 01 F 02 01 G 01 04 H 02 04 I want to insert some text if the field if the last column changes. It should look like this: Value 00 A 01 00 B 02 00 C 04 00 Value 01 (6 Replies)
Discussion started by: wenclu
6 Replies

6. Shell Programming and Scripting

Transpose field names from column headers to values in one column

Hi All, I'm looking for a script which can transpose field names from column headers to values in one column. for example, the input is: IDa;IDb;IDc;PARAM1;PARAM2;PARAM3; a;b;c;p1val;p2val;p3val; d;e;f;p4val;p5val;p6val; g;h;i;p7val;p8val;p9val; into the output like this: ... (6 Replies)
Discussion started by: popesk
6 Replies

7. Shell Programming and Scripting

How to compare a field value of a same column?

I have a file which has entries like as below, 10:29:07.32 GOOD 122 10:29:07.35 GOOD 124 10:29:09.97 BAD 122 10:29:09.97 BAD 124 10:29:18.66 ... (6 Replies)
Discussion started by: gobinath
6 Replies

8. Shell Programming and Scripting

how to specify the column(field) in sed command

the following command removes the first two characters of the first column, how can I change it to to remove the first two characters of the second column? sed 's/^..//' file1.txt > file2.txt Thanks Joseph (4 Replies)
Discussion started by: jdhahbi
4 Replies

9. Shell Programming and Scripting

Compare two files UNMATCH in solaris

I have these following code, which give me output of a match items. Can any please help me to reverse the code so that I can get UNMATCH items: #! /usr/bin/bash cut -d":" -f1 file261 | sort >file261a tr "\t" " " <file262 | cut -d" " -f2 | sort >file262a comm -12 file261a file262a ... (8 Replies)
Discussion started by: amir07
8 Replies

10. Shell Programming and Scripting

Need help with switching field/column values

Hi all, I need some help on switching field/column values. For example I have a file name data.txt which contains: a b a b a b and I want to switch a and b and save it to the same file. the file data.txt then will have: b a b a b a The problem is, well, I know how to... (7 Replies)
Discussion started by: sonyd8
7 Replies
Login or Register to Ask a Question