IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New question on list parsing
I do a df -k | grep foo
I am looking to see if my application foo is on this machine and if so run a script in /foo/lbin. Because of my disk layouts could have 248 file systems mounted on /foo/$filesystems so if I do
df -k | grep foo | awk '{Print $6}' | awk -F/ '(print $2}' will return foo 248 times.

Now up to 4 instances could be running
foo
foo1
foo2
foo3
and I only need to identify a single entity of foo to kick off the script so if foo2 and foo were running I need to kick off both /foo/lbin/script and /foo2/lbin/script
I could hardcode a case test for the 4 possible running areas but I have hundreds of these clusters and would rather do it once in a wrapper to determine which instance to run.

I have tried thinking of other ways to test if the application resides locally but df -k is extremely determinate.

so if my df returns
foo
foo
foo
foo
foo2
foo2
foo2
foo2

and the amount of returns vary from 48 to 246, what would be the easiest way to parse out foo and foo2?
I could write a tmp file.lock showing that I have already ran the script for this instance today but that seems clunky.

thanx,
bill


Any opinions expressed by me are mine alone, posted from my home computer, on my own time as a free american and do not reflect the opinions of any person or company that I have had professional relations with in the past 51 years. meep

reach me at [link|mailto:bill.oxley@cox.net|mailto:bill.oxley@cox.net]
New Dunno if this is easiest, but since you know awk
Just write a full awk script instead of a one-liner. Use hashmaps to determine if you've seen a particular name already.
Regards,

-scott anderson

"Welcome to Rivendell, Mr. Anderson..."
New I was afraid someone would suggest that :-)
Any opinions expressed by me are mine alone, posted from my home computer, on my own time as a free american and do not reflect the opinions of any person or company that I have had professional relations with in the past 51 years. meep

reach me at [link|mailto:bill.oxley@cox.net|mailto:bill.oxley@cox.net]
New brainbrammage, here is the solution
df -k | grep foo | awk '{Print $6}' | awk -F/ '(print $2}' | uniq
only returns one iteration. Forgot about uniq
thanx,
bill
Any opinions expressed by me are mine alone, posted from my home computer, on my own time as a free american and do not reflect the opinions of any person or company that I have had professional relations with in the past 51 years. meep

reach me at [link|mailto:bill.oxley@cox.net|mailto:bill.oxley@cox.net]
New Ar... I always forget the simple way to do it ;-)
Regards,

-scott anderson

"Welcome to Rivendell, Mr. Anderson..."
New Of course you forget, you only do OO AWK
===

Kip Hawley is still an idiot.

===

Purveyor of Doc Hope's [link|http://DocHope.com|fresh-baked dog biscuits and pet treats].
[link|http://DocHope.com|http://DocHope.com]
New Ha!
New I was actually just about to suggest it.
There is an amazing variety of little tools just perfect for a shell pipeline. Uniq is one of them. I find a new tool every once in a while.

Wade.


Is it enough to love
Is it enough to breathe
Somebody rip my heart out
And leave me here to bleed
 
Is it enough to die
Somebody save my life
I'd rather be Anything but Ordinary
Please



-- "Anything but Ordinary" by Avril Lavigne.

· my ·
· [link|http://staticsan.livejournal.com/|blog] ·
· [link|http://yceran.org/|website] ·

     question on list parsing - (boxley) - (7)
         Dunno if this is easiest, but since you know awk - (admin) - (1)
             I was afraid someone would suggest that :-) -NT - (boxley)
         brainbrammage, here is the solution - (boxley) - (4)
             Ar... I always forget the simple way to do it ;-) -NT - (admin) - (2)
                 Of course you forget, you only do OO AWK -NT - (drewk) - (1)
                     Ha! -NT - (Another Scott)
             I was actually just about to suggest it. - (static)

But if you draw a bow, draw the STRONG-est! YEEEEESSS! And if you use an arrow, use the LONGEST! OH YES!!
95 ms