awk parse result that match data from file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting awk parse result that match data from file
# 1  
Old 08-19-2015
awk parse result that match data from file

i run command that return this result,example :
Code:
gigabitethernet2/2/4:NotPresent, gigabitethernet2/1/17:UP, gigabitethernet2/1/10:UP, gigabitethernet2/1/5:UP,
gigabitethernet2/1/9:UP, gigabitethernet2/1/36:DOWN, gigabitethernet2/1/33:DOWN, gigabitethernet2/1/8:UP,
gigabitethernet2/1/51:NotPresent, gigabitethernet2/1/14:UP, gigabitethernet2/1/16:UP, gigabitethernet2/1/11:UP,
gigabitethernet2/1/4:UP, gigabitethernet2/1/44:DOWN, gigabitethernet2/1/22:UP, gigabitethernet2/1/30:UP, 
gigabitethernet2/2/3:NotPresent, gigabitethernet2/1/37:UP, gigabitethernet2/1/32:DOWN, gigabitethernet2/1/12:DOWN,
gigabitethernet2/1/24:DOWN, gigabitethernet2/1/43:DOWN, gigabitethernet2/1/49:DOWN, 
gigabitethernet2/1/20:UP

and i want to get only the values that are not in "up"
for example :
gigabitethernet2/1/43: DOWN ==> i want to get the value 43.
also i want to read list from file, so that the result will be checked with the data :
file ->1.cfg
data ->
Code:
1
4
7
43
46

because the value "43" is in the file, then the match will work and the "43" value with the "down" will be returned.

thnaks for the help!

Last edited by vbe; 08-19-2015 at 11:35 AM..
# 2  
Old 08-19-2015
Is there really a line break in the middle of gigabitethernet2/1
/12:DOWN
? Or maybe this entire string should be 1 line?
# 3  
Old 08-19-2015
The entire string should be ONE line...
I will try to edit and correct...
# 4  
Old 08-19-2015
Then, try
Code:
awk -F"[:/ ]" '$NF !~ /UP$/ {print $(NF-1)}' RS="[,\n]" file
4
36
33
51
44
3
32
12
24
43
49

I'm sorry the output is not what you posted as desired output, but this is what the file contains.
# 5  
Old 08-20-2015
Hi neutronscott there is "/" in the result.

RudiC i will try your solution

---------- Post updated at 02:49 AM ---------- Previous update was at 02:20 AM ----------

RudiC - the result that i got that only the values from the files were printed.
can i "hide" them?
and for the other result that i want- i didn't get it, altough the value "UP" exists.
# 6  
Old 08-30-2015
RudiC your solution worked.

is there a way to concat the result to a single row?
# 7  
Old 08-30-2015
Try setting ORS=" ".
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk , parse data from stacked columns

I am trying to rearrange stacked columns. Below is an excerpt of my data file: You can see there are two data columns stacked vertically. ITERATION ... (1 Reply)
Discussion started by: sav0
1 Replies

2. Programming

How to parse .nessus file to get result in human readable format?

Scripting Language: bash shell script, python I want to parse .nessus file in human readable format. If any one have any ideas please help me. (2 Replies)
Discussion started by: sk151993
2 Replies

3. Shell Programming and Scripting

awk to update file based on partial match in field1 and exact match in field2

I am trying to create a cronjob that will run on startup that will look at a list.txt file to see if there is a later version of a database using database.txt as the source. The matching lines are written to output. $1 in database.txt will be in list.txt as a partial match. $2 of database.txt... (2 Replies)
Discussion started by: cmccabe
2 Replies

4. Shell Programming and Scripting

awk to parse file and display result based on text

I am trying using awk to open an input file and check a column 2/field $2 and if there is a warning then that is displayed (variantchecker): G not found at position 459, found A instead. The attached Sample1.txt is that file. If in that column/field there is a black space, then the text after... (6 Replies)
Discussion started by: cmccabe
6 Replies

5. Shell Programming and Scripting

awk to split and parse unpredictable data

data.txt: CRITICAL: iLash: 97.00%, SqlPlus: 99.00%. Warning/critical thresholds: 95/98% I need to pull only the disknames: iLash and SqlPlus The following command will only pull iLash: echo "CRITICAL: iLash: 97.00%, SqlPlus: 99.00%. Warning/critical thresholds: 95/98%" | awk -F":"... (7 Replies)
Discussion started by: SkySmart
7 Replies

6. Shell Programming and Scripting

awk : Filter a set of data to parse header line and last field of multiple same match.

Hi Experts, I have a data with multiple entry , I want to filter PKG= & the last column "00060110" or "00088150" in the output file: ############################################################################################### PKG= P8SDB :: VGS = vgP8SOra vgP8SDB1 vgP8S001... (5 Replies)
Discussion started by: rveri
5 Replies

7. Shell Programming and Scripting

awk help: Match data fields from 2 files & output results from both into 1 file

I need to take 2 input files and create 1 output based on matches from each file. I am looking to match field #1 in both files (Userid) and create an output file that will be a combination of fields from both file1 and file2 if there are any differences in the fields 2,3,4,5,or 6. Below is an... (5 Replies)
Discussion started by: ambroze
5 Replies

8. Shell Programming and Scripting

Match look up file and find result

Hi I ahve a lookup file wiht seven words CD HT CAD HT T1D T2D BDanother file contain data like this CHRM1 P11229 Pirenzepine DAP000492 Peptic ulcer disease Approved T2D CHRM1 P11229 Glycopyrrolate DAP001116 Anesthetic Approved T2D CHRM1 P11229 ... (7 Replies)
Discussion started by: manigrover
7 Replies

9. Shell Programming and Scripting

AWK script to parse a data in a file

Hi Unix gurus.. I have a file which has below data, It has several MQ Queue statistics; QueueName= 'TEST1' CreateDate= '2009-10-30' CreateTime= '13.45.40' QueueType= Predefined QueueDefinitionType= Local QMinDepth= 0 QMaxDepth= 0 QueueName= 'TEST2' CreateDate= '2009-10-30'... (6 Replies)
Discussion started by: dd_psg
6 Replies

10. Shell Programming and Scripting

print out result from data file

i got a data file which contains all the pid,ppid,user,command,pcpu,start_time,status. I wanted to display out the pcpu which is greater than 0. i uses awk'{if($5 > 0){print}}' filename.txt but is printing out result which not i wanted. Is there any way which i can print out those pcpu which is... (8 Replies)
Discussion started by: thms_sum
8 Replies
Login or Register to Ask a Question