Sponsored Content
Top Forums UNIX for Beginners Questions & Answers awk based on first 5 filed of column Post 303007810 by MadeInGermany on Wednesday 22nd of November 2017 02:29:25 AM
Old 11-22-2017
If you only want a line filter then grep is perfect
Code:
grep '^46656' STG3TOUDCMATCH

If you later want to add more field-based filters or output formatting then use awk with its automatic field splitting
Code:
awk -F, '$1~/^46656/' STG3TOUDCMATCH

For example, you can add a condition "and field#2 must end with 56"
Code:
awk -F, '$1~/^46656/ && $2~/56$/' STG3TOUDCMATCH


Last edited by hicksd8; 04-26-2020 at 08:35 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

AWK: how to get average based on certain column

Hi, I'm new to shell programming, can anyone help me on this? I want to do following operations - 1. Average salary for each country 2. Total salary for each city and data that looks like - salary country city 10000 zzz BN 25000 zzz BN 30000 zzz BN 10000 yyy ZN 15000 yyy ZN ... (3 Replies)
Discussion started by: shell123
3 Replies

2. Emergency UNIX and Linux Support

awk cut column based on string

Using awk I required to cut out column contain word "-Tag" regardles of any order of contents and case INsensitive -Tag:messages -P:/var/log/messages -P:/var/log/maillog -K:Error -K:Warning -K:critical Please Guide ...... --Shirish Shukla ---------- Post updated at 05:58 AM... (15 Replies)
Discussion started by: Shirishlnx
15 Replies

3. Shell Programming and Scripting

KSH or Awk first and last line based on column 2

Example: 10.160.101.160,0707073711,22.203.203.200 10.160.101.160,0707075132,22.203.210.249 10.160.101.160,0707085436,22.203.210.249 10.160.101.160,0707091712,22.203.221.176 10.160.101.160,0707091811,22.203.221.176 10.160.101.160,0707091845,22.203.221.176... (1 Reply)
Discussion started by: BrownBob
1 Replies

4. Shell Programming and Scripting

Help with awk in counting characters based on a column

Hello, I am using Awk in UBUNTU 12.04. I have a file as follows with 2172 rows and 44707 columns. ABO and GPO are the names of my populations. ABO_1 1 2 ABO_1 1 2 ABO_2 1 1 ABO_2 1 2 GPO_1 1 1 GPO_1 2 2 GPO_2 1 0 GPO_2 2 0I want to count the number of 1s and 2s in... (7 Replies)
Discussion started by: Homa
7 Replies

5. Shell Programming and Scripting

Pick the column value based on another column using awk or CUT

My scenario is that I need to pick value from third column based on fourth column value, if fourth column value is 1 then first value of third column.Third column (2|3|4|6|1) values are cancatenated. Please someone help me to resolve this issue. Source column1 column2 column3 column4... (2 Replies)
Discussion started by: Ganesh L
2 Replies

6. Shell Programming and Scripting

awk filter based on column value (variable value)

Hi, I have a requirement to display/write the 3rd column from a file based on the value in the column 3. Ex: Data in the File (comma delimited) ID,Value,Description 1,A,Active 1,I,Inactive 2,S,Started 1,N,None 2,C,Completed 2,F,Failed I need to first get a list of all Unique IDs in... (7 Replies)
Discussion started by: kiranredz
7 Replies

7. Shell Programming and Scripting

Sort based on column 1, not working with awk

Hi Guru, I need some help regarding awking the output so it only show the first line (based on column) of each row. So If column has 1, three row, then it only show the first line of that row, based on similar character in column 1. So i am trying to achieve a sort, based on column one and... (3 Replies)
Discussion started by: Junes
3 Replies

8. Shell Programming and Scripting

awk to sum a column based on duplicate strings in another column and show split totals

Hi, I have a similar input format- A_1 2 B_0 4 A_1 1 B_2 5 A_4 1 and looking to print in this output format with headers. can you suggest in awk?awk because i am doing some pattern matching from parent file to print column 1 of my input using awk already.Thanks! letter number_of_letters... (5 Replies)
Discussion started by: prashob123
5 Replies

9. Shell Programming and Scripting

Transpose matrix based on second column using awk

Hi, Is it possible to transpose the matrix like this using awk ? Many thanks in advance Input abc Name_1 0 abc Name_2 1 abc Name_3 2 abc Name_4 0.4 def Name_1 0 def Name_2 9 def Name_3 78 def Name_4 1 Output abc def Name_1 0 ... (4 Replies)
Discussion started by: quincyjones
4 Replies

10. UNIX for Beginners Questions & Answers

Awk/sed summation of one column based on some entry in first column

Hi All , I am having an input file as stated below Input file 6 ddk/djhdj/djhdj/Q 10 0.5 dhd/jdjd.djd.nd/QB 01 0.5 hdhd/jd/jd/jdj/Q 10 0.5 512 hd/hdh/gdh/Q 01 0.5 jdjd/jd/ud/j/QB 10 0.5 HD/jsj/djd/Q 01 0.5 71 hdh/jjd/dj/jd/Q 10 0.5 ... (5 Replies)
Discussion started by: kshitij
5 Replies
COLRM(1)						    BSD General Commands Manual 						  COLRM(1)

NAME
colrm -- remove columns from a file SYNOPSIS
colrm [start [stop]] DESCRIPTION
The colrm utility removes selected columns from the lines of a file. A column is defined as a single character in a line. Input is read from the standard input. Output is written to the standard output. If only the start column is specified, columns numbered less than the start column will be written. If both start and stop columns are spec- ified, columns numbered less than the start column or greater than the stop column will be written. Column numbering starts with one, not zero. Tab characters increment the column count to the next multiple of eight. Backspace characters decrement the column count by one. ENVIRONMENT
The LANG, LC_ALL and LC_CTYPE environment variables affect the execution of colrm as described in environ(7). EXIT STATUS
The colrm utility exits 0 on success, and >0 if an error occurs. SEE ALSO
awk(1), column(1), cut(1), paste(1) HISTORY
The colrm command appeared in 3.0BSD. BSD
August 4, 2004 BSD
All times are GMT -4. The time now is 07:32 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy