awk some columns from file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting awk some columns from file
# 1  
Old 08-26-2010
awk some columns from file

I have a file that has a list in this format:
Code:
abcdefg|mia21acs.acs.oaklahoma.net|10.83.19.21|||PROV|ADTHNION21E|USA|DLAR|CISCO||OS|1.0.7.10
abcdefg|cle22acs.acs.oaklahoma.net|10.83.19.22|||PROV|ADTHNION22E|USA|DLAR|CISCO||OS|1.0.7.10

I need to pull the red highlighed fileds so the output looks like this:
Code:
MIA.ADTHNION21E
CLE.ADTHNION22E

I fumbled around but can't get it right, this is what I have so far:
Code:
cat list | grep "\.acs" | nawk 'BEGIN {FS="|"} {print ""$2"."$7""}' | nawk 'BEGIN {FS="."} {print $1"."$5}'

# 2  
Old 08-26-2010
Code:
awk -F\| '/\.acs/{print toupper(substr($2,1,3))"."$7}' list

This User Gave Thanks to bartus11 For This Post:
# 3  
Old 08-29-2010
Code:
while(<DATA>){
  print uc($1),".",$2,"\n" if /^[^\|]*\|([a-z]{3})(?:[^\|]*\|){5}([^\|]*)/;
}
__DATA__
abcdefg|mia21acs.acs.oaklahoma.net|10.83.19.21|||PROV|ADTHNION21E|USA|DLAR|CISCO||OS|1.0.7.10
abcdefg|cle22acs.acs.oaklahoma.net|10.83.19.22|||PROV|ADTHNION22E|USA|DLAR|CISCO||OS|1.0.7.10

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Awk: compare values in two columns of the same file

I'm trying to learn awk, but I've hit a roadblock with this problem. I have a hierarchy stored in a file with 3 columns: id name parentID 4 D 2 2 B 1 3 C 1 1 A 5 I need to check if there are any values in column 3 that are not represented anywhere in column 1. I've tried this: awk '{arr;}... (7 Replies)
Discussion started by: kaktus
7 Replies

2. Shell Programming and Scripting

awk dynamically append columns into file

Hi, I have a large data file, want to separate it into 100 part and export one specific field as a file; then I want to append each part's column into one file. How to realize that? 1 2 3 1 2 3 4 2 2 3 4 3 3 3 4 4 3 4 5 5 3 4 5 6 I want the last column of the data file, e.g divide it... (5 Replies)
Discussion started by: wanliushao
5 Replies

3. Shell Programming and Scripting

awk filter by columns of file csv

Hi, I would like extract some lines from file csv using awk , below the example: I have the file test.csv with in content below. FLUSSO;COD;DATA_LAV;ESITO ULL;78;17/09/2013;OL ULL;45;05/09/2013;Apertura NP;45;13/09/2013;Riallineamento ULLNP;78;17/09/2013;OL NPG;14;12/09/2013;AperturaTK... (6 Replies)
Discussion started by: giankan
6 Replies

4. Shell Programming and Scripting

Awk print all columns in delimited file

text file example 1,222222222222,333,444444444444444 111111111,22,33333333,444 desired output 1 222222222222 333 444444444444444 111111111 22 33333333 444I have a delimeted file which I want to print in a table like format. The... (10 Replies)
Discussion started by: Calypso
10 Replies

5. Shell Programming and Scripting

Need to include two more columns in the file using awk

Hi, I have a input file with many records as below: 1J4RR4GG0BC508200 68646 1 N M i want my output file to be like with columns included dgismdh and timestamp : Example: 1J4RR4GG0BC508200 68646 1 N M dgismdh 2012-02-21 07:22:25.98591 How to do it.can we do using awk? Pls help. (6 Replies)
Discussion started by: sonam273
6 Replies

6. UNIX for Dummies Questions & Answers

Awk, ouptut columns in a file by column name

Hi, i am posting this after not finding proper solution in any other discussion threads I have a text data file with the first row as the column header names. The file can be comma, tab, space, pipeline, .... delimited Example of a pipeline delimited: file1.txt... (14 Replies)
Discussion started by: ysrini
14 Replies

7. Shell Programming and Scripting

grep/awk to only print lines with two columns in a file

Hey, Need some help for command to print only lines with two columns in a file abc 111 cde 222 fgh ijk 2 klm 12 23 nop want the ouput to be abc 111 cde 222 ijk 2 Thanks a lot in advance!!! (3 Replies)
Discussion started by: leo.maveriick
3 Replies

8. Shell Programming and Scripting

Awk to add columns from a file into an existing file

Hi! I would need some help to add the last two columns of one file into another file using awk (or something similar). For example, I have: file 1: file 2: car book day root lag bar look pay boot tag tar took may moot sag I want to have:... (5 Replies)
Discussion started by: coconaza
5 Replies

9. Shell Programming and Scripting

using awk to print some columns of a file

Hi, i have a file with content 00:01:20.613 'integer32' 459254 00:01:34.158 459556 00:01:36.626 'integer32' 459255 and i want to print only output as below 00:01:20.613 459254 00:01:34.158 459556 00:01:36.626 459255 i dont want the word 'integer32' which is the second column. i... (2 Replies)
Discussion started by: dealerso
2 Replies

10. Shell Programming and Scripting

Using awk to substitute columns from one file into another

Hi, I am new to this forum and my script skills are very weak. I have this file (file 1) that contains 3 columns (tab delimited): kyle start stop john start stop joe start stop And I want to replace name (column 1) from another file. This other file has two columns, one is the... (4 Replies)
Discussion started by: kylle345
4 Replies
Login or Register to Ask a Question