Sponsored Content
Full Discussion: awk/grep type question
Top Forums Shell Programming and Scripting awk/grep type question Post 302379867 by hcclnoodles on Saturday 12th of December 2009 07:39:34 PM
Old 12-12-2009
awk/grep type question

Hi there, I have a Solaris machine with an ifconfig output similar to below

Code:
lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
        inet 127.0.0.1 netmask ff000000 
e1000g0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
        inet 10.0.0.1 netmask ffff0000 broadcast 10.0.255.255
        ether 0:14:4f:1f:xx:xx 
e1000g0:1: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
        inet 10.0.0.2 netmask ffff0000 broadcast 10.0.255.255
e1000g0:2: flags=201000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4,CoS> mtu 1500 index 2
        zone virtual-server67
        inet 10.0.0.3 netmask ffff0000 broadcast 10.0.255.255
e1000g0:3: flags=201000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4,CoS> mtu 1500 index 2
        zone virtual-server68
        inet 10.0.0.4 netmask ffff0000 broadcast 10.0.255.255

As you can see I have one physical interface called e1000g0 and three subsequent virtual interfaces on e1000g0. The first one is just a regular secondary virtual interface, but the second and third are attached to Solaris Zones (virtual servers) and subsequently have an extra line in the output defining the zone it is attahced to (in red above). I have to write a process that will cycle through theses 4 interfaces (in this case 1 physical and 3 virtual) populating a variable, lets call it VAR, with the virtual server name found on the lines highlighted in red above (additional example below)

Code:
zone virtual-server68

But where there is no "zone <virtualserver name>" line for an interface, be it Physical or Virtual (as with e1000g0 and e1000g0:1) I want to just poulate VAR with a "-"

My question is really, whilst I am happy using awk to set VAR with the value of that line if it existed on ALL interfaces, I am a little unsure as to how I use it to make the determination of whether the line exists for a interface then either grab the value or set it to "-" accordingly ?

would i need to use a mixture of tools to achieve this or can it all be done within awk?

any help on this would be greatly appreciated
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

question on sed grep awk from variable

i am still confusing on how to use sed, grep and awk if the input is not a file but a variable. such as: a="hello world" b="how are you" c="best wish to you" d="222,333,444" what if i want to check which variable $a,$b,$c,$d have contain "you" what if i want to replace the word "you"... (9 Replies)
Discussion started by: 3Gmobile
9 Replies

2. Shell Programming and Scripting

Awk type checking

Hello, How to check if two variables( fields in awk) have the same datatype ( INTEGER , REAL, TEXT ) ? (2 Replies)
Discussion started by: scotty_123
2 Replies

3. Shell Programming and Scripting

Problem with type-casting in awk

Hi I'm trying to write a script which takes an integer as input and checks for files with size > input and displays it on screen. The code I've tried : echo 'Enter the min file size expected' read filesize du -ah <folder name> | awk -F: '$1>int(filesize) {print $1,$2)' is always... (28 Replies)
Discussion started by: vivek.bharadwaj
28 Replies

4. Shell Programming and Scripting

General question about the relationship between KSH and sed/grep/awk etc

Greetings all, Unix rookie here, just diving into ksh scripting for the first time. My question may seem confusing but please bear with me: If I'm understanding everything I'm reading properly, it seems like the ksh language itself doesn't have a lot of string manipulation functions of... (2 Replies)
Discussion started by: DalTXColtsFan
2 Replies

5. Shell Programming and Scripting

Grep to find single instances of each ERROR type

i have a file that contents multiple instances of the same ERROR.Below the content of the file ERROR_FILE.txt Archiver6.log:2009-05-25 17:58:44,385 ERROR - CleanLPDataMessage: Missing Intervals: 2 Archiver6.log:2009-05-25 18:27:36,056 ERROR - CleanLPDataMessage: Missing Intervals: 5... (5 Replies)
Discussion started by: ali560045
5 Replies

6. Shell Programming and Scripting

awk vs grep question

Hello, I am trying to use awk instead of grep command. Is there a way I can search for a pattern and show 10 lines before it (grep -B) using awk ot nawk? (5 Replies)
Discussion started by: alekkz
5 Replies

7. Shell Programming and Scripting

regex, awk, grep question "how to"

I've been working on this for 2 days and I'm not getting far. It is time to turn to you guys. With the data below, I am trying to create a file that looks like this: I'd like to use some form of egrep I think. AY#box#P04prod_to_contingency s AY#cmd#P04dump_cont_db s AY#cmd#P04get_on_ice_job s... (2 Replies)
Discussion started by: rawbi01
2 Replies

8. Shell Programming and Scripting

Grep / awk /sed question

Hi All, I have a file with following sample data. I am also attaching the file. (Est) (Est) Jobs Sch Workstation Job Stream SchedTime State Pr Start Elapse # OK Lim POOL #ACR_BILLING 0005 08/15 ... (2 Replies)
Discussion started by: Kevin Tivoli
2 Replies

9. UNIX for Dummies Questions & Answers

Count occurrence of string (based on type) in a column using awk

Hello, I have a table that looks like what is shown below: AA BB CC XY PQ RS AA BB CC XY RS I would like the total counts depending on the set they belong to: if search pattern is in {AA, BB, CC} --> count them as Type1 | wc -l (3 Replies)
Discussion started by: Gussifinknottle
3 Replies
ppmtosixel(1)						      General Commands Manual						     ppmtosixel(1)

NAME
ppmtosixel - convert a portable pixmap into DEC sixel format SYNOPSIS
ppmtosixel [-raw] [-margin] [ppmfile] DESCRIPTION
Reads a portable pixmap as input. Produces sixel commands (SIX) as output. The output is formatted for color printing, e.g. for a DEC LJ250 color inkjet printer. If RGB values from the PPM file do not have maxval=100, the RGB values are rescaled. A printer control header and a color assignment table begin the SIX file. Image data is written in a compressed format by default. A printer control footer ends the image file. OPTIONS
-raw If specified, each pixel will be explicitly described in the image file. If -raw is not specified, output will default to com- pressed format in which identical adjacent pixels are replaced by "repeat pixel" commands. A raw file is often an order of magni- tude larger than a compressed file and prints much slower. -margin If -margin is not specified, the image will be start at the left margin (of the window, paper, or whatever). If -margin is speci- fied, a 1.5 inch left margin will offset the image. PRINTING
Generally, sixel files must reach the printer unfiltered. Use the lpr -x option or cat filename > /dev/tty0?. BUGS
Upon rescaling, truncation of the least significant bits of RGB values may result in poor color conversion. If the original PPM maxval was greater than 100, rescaling also reduces the image depth. While the actual RGB values from the ppm file are more or less retained, the color palette of the LJ250 may not match the colors on your screen. This seems to be a printer limitation. SEE ALSO
ppm(5) AUTHOR
Copyright (C) 1991 by Rick Vinci. 26 April 1991 ppmtosixel(1)
All times are GMT -4. The time now is 07:51 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy