filtering column #7


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting filtering column #7
# 1  
Old 06-07-2010
filtering column #7

Hi,

I want to filter a file that contains 11 columns. Basically I want to filter based on column 7.

The file that I have looks like this:
Code:
1  3  4  AB  45  run  PPPPPPPOOOOOOOLLLLLLLL...  5  9  ui  [
1  3  4  AB  45  run  PPPPPPPOOOOOOOLLLLLLLLL..  5  9  ui  [
1  3  4  AB  45  run  PEEEPPTTTTTPOOOLLLOOLLV...  5  9  ui  [
1  3  4  AB  45  run  PEPTOLLLPOLOPEPEPEPEPEPEE  5  9  ui  [

So for column 7 i want to delete lines that have a . OR more than 2 .

So if I were to delete lines with a . then the output would look like this:

Code:
1  3  4  AB  45  run  PEPTOLLLPOLOPEPEPEPEPEPEE  5  9  ui  [

And if I were to delete lines with more than 2 . then the output would look like this

Code:
1  3  4  AB  45  run  PPPPPPPOOOOOOOLLLLLLLLL..  5  9  ui  [
1  3  4  AB  45  run  PEPTOLLLPOLOPEPEPEPEPEPEE  5  9  ui  [

Thanks
# 2  
Old 06-07-2010
Single dot
Code:
awk ' $7 !~ "\\." ' file

More than two dots
Code:
awk ' $7 !~ "\\.\{3,\}" ' file

# 3  
Old 06-07-2010
delete lines with any number of ".":
Code:
awk '$7!~/\./' infile > outfile

delete lines that have more than 2 ".":
Code:
awk '$7!~/\.\.\./' infile > outfile

# 4  
Old 06-07-2010
Code:
perl -ane 'print if $F[6] !~ /\./' file

and
Code:
perl -ane 'print if $F[6] !~ /\./ || $F[6] =~ /[A-Z]\.\.$/' file

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Filtering records of a csv file based on a value of a column

Hi, I tried filtering the records in a csv file using "awk" command listed below. awk -F"~" '$4 ~ /Active/{print }' inputfile > outputfile The output always has all the entries. The same command worked for different users from one of the forum links. content of file I was... (3 Replies)
Discussion started by: sunilmudikonda
3 Replies

2. UNIX for Beginners Questions & Answers

Filtering based on column values

Hi there, I am trying to filter a big file with several columns using values on a column with values like (AC=5;AN=10;SF=341,377,517,643,662;VRT=1). I wont to filter the data based on SF= values that are (bigger than 400) ... (25 Replies)
Discussion started by: daashti
25 Replies

3. Shell Programming and Scripting

Filtering first file columns based on second file column

Hi friends, I have one file like below. (.csv type) SNo,data1,data2 1,1,2 2,2,3 3,3,2 and another file like below. Exclude data1 where Exclude should be treated as column name in file2. I want the output shown below. SNo,data2 1,2 2,3 3,2 Where my data1 column got removed from... (2 Replies)
Discussion started by: ks_reddy
2 Replies

4. Shell Programming and Scripting

Filtering lines for column elements based on corresponding counts in another column

Hi, I have a file like this ACC 2 2 21 aaa AC 443 3 22 aaa GCT 76 1 33 xxx TCG 34 2 33 aaa ACGT 33 1 22 ggg TTC 99 3 44 wee CCA 33 2 33 ggg AAC 1 3 55 ddd TTG 10 1 22 ddd TTGC 98 3 22 ddd GCT 23 1 21 sds GTC 23 4 32 sds ACGT 32 2 33 vvv CGT 11 2 33 eee CCC 87 2 44... (1 Reply)
Discussion started by: polsum
1 Replies

5. Shell Programming and Scripting

Perl: filtering lines based on duplicate values in a column

Hi I have a file like this. I need to eliminate lines with first column having the same value 10 times. 13 18 1 + chromosome 1, 122638287 AGAGTATGGTCGCGGTTG 13 18 1 + chromosome 1, 128904080 AGAGTATGGTCGCGGTTG 13 18 1 - chromosome 14, 13627938 CAACCGCGACCATACTCT 13 18 1 + chromosome 1,... (5 Replies)
Discussion started by: polsum
5 Replies

6. Shell Programming and Scripting

Filtering Multiple variables from a single column

Hi, I am currently filtering a file, "BUILD_TIMES", that has multiple column of information in it. An example of the data is as follows; Fri Nov 5 15:31:33 2010 00:28:17 R7_BCGNOFJ_70.68 Fri Nov 5 20:57:41 2010 00:07:21 R7_ADJCEL_80.6 Wed Nov 10 17:33:21 2010 00:01:13 R7_BCTTEST3_80.1X... (7 Replies)
Discussion started by: crunchie
7 Replies

7. Shell Programming and Scripting

Match column 3 in file1 to column 1 in file 2 and replace with column 2 from file2

Match column 3 in file1 to column 1 in file 2 and replace with column 2 from file2 file 1 sample SNDK 80004C101 AT XLNX 983919101 BB NETL 64118B100 BS AMD 007903107 CC KLAC 482480100 DC TER 880770102 KATS ATHR 04743P108 KATS... (7 Replies)
Discussion started by: rydz00
7 Replies

8. Shell Programming and Scripting

Changing one column of delimited file column to fixed width column

Hi, Iam new to unix. I have one input file . Input file : ID1~Name1~Place1 ID2~Name2~Place2 ID3~Name3~Place3 I need output such that only first column should change to fixed width column of 15 characters of length. Output File: ID1<<12 spaces>>Name1~Place1 ID2<<12... (5 Replies)
Discussion started by: manneni prakash
5 Replies

9. UNIX for Dummies Questions & Answers

Filtering records of a file based on a value of a column

Hi all, I would like to extract records of a file based on a condition. The file contains 47 fields, and I would like to extract only those records that match a certain value in one of the columns, e.g. COL1 COL2 COL3 ............... COL47 1 XX 45 ... (4 Replies)
Discussion started by: risk_sly
4 Replies

10. Shell Programming and Scripting

Report running processes in a specific format (tricky column filtering)

First off I have HP Unix, so as far as I can tell the PS command does not let me list specifically which columns I would like or what order I would like to see them. I want to make a custom PS script for checking what SAS process are running. I want it to take 1 argument of user name and only... (6 Replies)
Discussion started by: goldfish
6 Replies
Login or Register to Ask a Question