Sponsored Content
Top Forums Shell Programming and Scripting awk comparison with two patterns Post 302790569 by ibanezpete on Friday 5th of April 2013 06:48:45 PM
Old 04-05-2013
Thanks for explaining that, makes more sense now I see it talked through! I have been running this for a couple of days to check the results and noticed that I have oversimplified the path names when I originally phrased the question. The result is that full path names are not printed and likewise all versions of certain models are being printed.

*hangs head in shame*

Thats clearly my fault for incorrectly phrasing the question. For the task as described the command worked as required Smilie

Here are the differences with filenames:

1. The end of the filename is _Software.bak (This never changes)

//servername.com/version/panasonic2,6_3.0.4 (What I originally posted)
//servername.com/panasonic3/version/panasonic2,6_3.0.4_Software.bak (What the file path actually is)

2. Some of the folders contain part of the software version in a higher folder (panasonic3 or pan6 for example). This means a comparison based on anything before the first _ will not show these two results as unique when in actual fact one is to be printed and the other discarded.

Code:
//servername.com/pan7/version/panasonic3,1_7.1.3_Software.bak
//servername.com/pan6/version/panasonic3,1_6.7.1_Software.bak

I realise I have now rephrased the question. This will make things a more difficult but awk seems a powerful tool. I'll start working on it at my end.

A full file list might look like this:

Code:
//servername.com/pan7/version/panasonic3,1_7.1.3_Software.bak
//servername.com/pan6/version/panasonic3,2_6.8_Software.bak
//servername.com/panasonic1/version/panasonic1,1_1.1.1_Software.bak
//servername.com/pan6/version/panasonic3,1_6.7.1_Software.bak
//servername.com/panasonic3/version/panasonic2,6_3.0.2_Software.bak
//servername.com/pan6/version/panasonic3,2_6.2.3_Software.bak
//servername.com/panasonic3/version/panasonic2,6_3.0.4_Software.bak

And would sort to:

Code:
//servername.com/pan7/version/panasonic3,1_7.1.3_Software.bak
//servername.com/pan6/version/panasonic3,2_6.8_Software.bak
//servername.com/panasonic1/version/panasonic1,1_1.1.1_Software.bak
//servername.com/panasonic3/version/panasonic2,6_3.0.4_Software.bak


Last edited by Scrutinizer; 04-06-2013 at 05:26 PM.. Reason: code tags
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

multiple comparison in awk

I have an input file. Each line in it has several characters. If the first three characters of the line is '000' or '001' or '002' or '003', I need to print it in output. How can I do this in awk. I am able to do if the search string is only one (let us say 000). cat <filename> | awk... (1 Reply)
Discussion started by: paruthiveeran
1 Replies

2. Shell Programming and Scripting

awk comparison with variable

hi, I want to compare i variable in the awk statement but its not working out. Pl help me out If we do the comparison like this its OK, cat sample | awk -F" ", '{if ($1=="1-Sep-2009") print $1,$2,$3,$4,$5}' But if u use a variable instead of "1-Sept-2009", it does not return anything,... (2 Replies)
Discussion started by: asadlone
2 Replies

3. Shell Programming and Scripting

Comparison and editing of files using awk.(And also a possible bug in awk for loop?)

I have two files which I would like to compare and then manipulate in a way. File1: pictures.txt 1.1 1.3 dance.txt 1.2 1.4 treehouse.txt 1.3 1.5 File2: pictures.txt 1.5 ref2313 1.4 ref2345 1.3 ref5432 1.2 ref4244 dance.txt 1.6 ref2342 1.5 ref2352 1.4 ref0695 1.3 ref5738 1.2... (1 Reply)
Discussion started by: linuxkid
1 Replies

4. Shell Programming and Scripting

awk comparison

Hello all, Probably a very simple question, I am stuck with a small part of a code: I am trying to do a comparison to get the maximum value of column 6 if columns 1, 4 and 5 of two or more rows match. Here is what I am doing: awk -F'\t' '{if ($6 > a)a=$6}END{for (i in a) print i"\t"a}' ... (4 Replies)
Discussion started by: jaysean
4 Replies

5. Shell Programming and Scripting

File comparison using awk

my files are as follows fileA sepearated by tab /t 00 lieferungen 00 attractiop 01 done 02 forness 03 rasp 04 alwaysisng 04 funny 05 done1 fileB funnymou120112 funnymou234470 mou3raspnhdhv rddfgmoudone1438748 so all those record which are greater than 3 and which are not... (6 Replies)
Discussion started by: rajniman
6 Replies

6. Shell Programming and Scripting

Need help with simple comparison in AWK

Hi, I'm new to AWK and I'm having problems comparing a field to a string variable. /ARTIST/ {x = $2} $1 ~ x {print $0}My code tries to find a record with the string "ARTIST". Once it finds it, it stores the second field of the record into a variable. I don't know what the problem is for the... (7 Replies)
Discussion started by: klusps
7 Replies

7. Shell Programming and Scripting

awk comparison not working

Can you please help me on belw awk comparsion which doest not work cat employee_list NAME Last-login Jack 03/25/2013 Maneul 03/26/2013 Eric 03/26/2013 Samuel 03/28/2013 loak 03/29/2013 zac 03/29/2013 this is my awk .. it gives me error cat employee_list | awk '(($2=='date... (3 Replies)
Discussion started by: Sara_84
3 Replies

8. Shell Programming and Scripting

File comparison using awk

Hi All, i have two files file1 ,file 2 file 1 col1|col2|col3|col4|col5|col6|col7|col8 11346925|0|2009-09-20|9999-12-31|100|0 11346925|0|2009-09-20|9999-12-31|120|0 12954311|0|2009-09-11|9999-12-31|100|0 12954311|0|2009-07-23|2999-12-31|120|0 12954312|0|2009-09-11|9999-12-31|100|0... (9 Replies)
Discussion started by: mohanalakshmi
9 Replies

9. Shell Programming and Scripting

awk if comparison with variable

Hi , Need help, p for value in `awk -F, '{print $1 }' ad | uniq` do x=$(echo $value) echo $x echo `awk -F, '{if( $1 == $x) sum = sum + $8 } END{print sum}' ad` --- not working echo `awk -F, '{if($1 == “MT”) sum = sum + $8 } END{print sum}' ad` -- Working but hard coded done; ad... (4 Replies)
Discussion started by: nadeemrafikhan
4 Replies

10. Shell Programming and Scripting

awk comparison of dates

I need to use awk to return lines in multiple files that contain a date between a start date and end date. The format of the date is as seen in column 3 in the following line. A,1458147240,Mar 30 2015 12:54:00PM,s15u4chn ,2,GPS Major Alarm `clear`,component.Channel,10,15,0,138,183,,,Mar 16... (4 Replies)
Discussion started by: randman1
4 Replies
FSTOBDF(1)						      General Commands Manual							FSTOBDF(1)

NAME
fstobdf - generate BDF font from X font server SYNOPSIS
fstobdf [ -server servername ] -fn fontname DESCRIPTION
The fstobdf program reads a font from a font server and prints a BDF file on the standard output that may be used to recreate the font. This is useful in testing servers, debugging font metrics, and reproducing lost BDF files. OPTIONS
-server servername This option specifies the server from which the font should be read. servername must be specified in one of the formats defined in the Font Server Names section of X(7). If not specified, the server name in the FONTSERVER environment variable is used. -fn fontname This option specifies the font for which a BDF file should be generated. ENVIRONMENT
FONTSERVER The default server to use. The server name must be specified in one of the formats defined in the Font Server Names section of X(7). SEE ALSO
xfs(1), bdftopcf(1), showfont(1), fslsfonts(1), X(7). AUTHOR
Olaf Brandt, Network Computing Devices Dave Lemke, Network Computing Devices Jim Fulton, MIT X Consortium X Version 11 fstobdf 1.0.5 FSTOBDF(1)
All times are GMT -4. The time now is 11:22 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy