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
# 15  
Old 08-30-2015
Hi, x is an empty variable, since it was not used before. In awk it automatically gets the value "" (in string context) when it is created. So it is another way of writing "" (the replacement part of the sub() command has a string context)

The variable name is chosen, because it is a bit akin to "x'ing out" a bit of text.

Last edited by Scrutinizer; 08-30-2015 at 03:42 PM..
This User Gave Thanks to Scrutinizer For This Post:
# 16  
Old 08-30-2015
x is a variable that never gets a value assigned to it. sub(".*/",x,$1) in the field $1 substitute the first instance of ".*/" for "".
This User Gave Thanks to Aia For This Post:
# 17  
Old 08-30-2015
sorry to ask again, the s=s and the $1 all alone there? Never seen OFS on its own, always something like OFS="whatever"
# 18  
Old 08-30-2015
Actually, they are not alone, it is the concatenation of all of them as in:
Code:
s=s $1 OFS

OFS stands for Output Field Separator and by default is a single space

Last edited by Aia; 08-30-2015 at 04:18 PM.. Reason: grammar
This User Gave Thanks to Aia For This Post:
# 19  
Old 08-30-2015
Quote:
Originally Posted by Kibou
sorry to ask again, the s=s and the $1 all alone there? Never seen OFS on its own, always something like OFS="whatever"
Hi Kibou, in addition to what Aia said, the string s is empty when created, and then each time it is appended with the first field ($1) and OFS (by default a space), so the first time, s contains:
4
, the second time
4 36
then
4 36 33
.. and so on...
This User Gave Thanks to Scrutinizer For This Post:
# 20  
Old 08-30-2015
Thank you! I understand it now.
Thanks for your time and effort, to both of you.
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