want to extract all column which have particular value
I want to separate the column on the basis of $7=-1 or $7=1 value. So is there awk command to doing this?
10 100009838 100009947 ENST00000324109 ENSE00001424407 1 -1
10 100042193 100042573 ENST00000370418 ENSE00001887192 9 -1
10 100048758 100048876 ENST00000370418 ENSE00003381123 8 -1
10 100048767 100048876 ENST00000441382 ENSE00001655587 5 -1
10 100054347 100054446 ENST00000370418 ENSE00000811303 7 -1
10 100054347 100054446 ENST00000441382 ENSE00000811303 4 -1
10 100057013 100057152 ENST00000370418 ENSE00000811302 6 -1
10 100057013 100057152 ENST00000441382 ENSE00000811302 3 -1
10 100063614 100063725 ENST00000370418 ENSE00000811301 5 -1
10 100063614 100063725 ENST00000441382 ENSE00000811301 2 -1
10 100065188 100065370 ENST00000370418 ENSE00000811300 4 -1
10 100065188 100065394 ENST00000441382 ENSE00001605944 1 -1
10 1000677 1000868 ENST00000360803 ENSE00003613229 7 1
10 1000677 1000868 ENST00000491635 ENSE00003567401 5 1
10 100069714 100069869 ENST00000370418 ENSE00003404628 3 -1
10 100075911 100076107 ENST00000370418 ENSE00003305953 2 -1
10 100081403 100081869 ENST00000370418 ENSE00001452668 1 -1
Thanks in advance
• 1,426 views
•
link
2 answers
awk 'BEGIN{OFS=FS="\t"}{print $0>$7".txt"}' inputFile
• 0 views
•
link
I know this question has been answered prior, but you could also solve this issue using a small Python script, as detailed below:
file = open(file_name)
final_list = []
for item in file:
line = item.split()
if(line[6] == "1" or line[6] == "-1"):
final_list.append(item)
file.close()
Hope this helped!
• 0 views
•
link
Log in to answer this question.
Please clarify if you want to separate all rows that have either
1or-1into two separate files.You are asking about column 7 but have not clarified what you want to do with the rest of the columns.