Hello.
I'm hoping somebody could help me figure out the following.
I have data that I've pulled down from a website using invoke-webrequest. I've got the data cleaned up and now is in an system.string type object. I want to create a hash table and possibly convert to a pscustomobject, but...
My data looks like the following:
id 34
name SERVERABC
port_count 2
type generic
mask 1111111111111111111111111111111111111111111111111111111111111111
iogrp_count 4
status online
site_id
site_name
host_cluster_id
host_cluster_name
WWPN 5001438002A3005A
node_logged_in_count 8
state active
WWPN...
Thanks for your suggestions..
I ended up just filtering out the "grapes" into a 2nd file. Then doing something like
awk 'NR==FNR && !x[$4,$5]++' wanted_info.txt print_this_if_not_in_first_file.txt
Thanks!
I have a file that looks like this:
apple4 yellow
apple1 red
apple6 blue
apple3 green
grape red
grape purple
apple68 yellow
apple32 red
apple98 orange
grape yellow
I would like to remove duplicate lines using the following:
awk '!x[$2]++'
However I only want to remove duplicates if $1...
Wondering if anybody could help...
I've clipped some of the raw data, but you'll get the general idea.
Raw data:
CL1-A
CL1-A
CL1-A
CL1-A
CL1-A
CL1-A
CL1-A
CL1-A
CL1-A
CL1-A
CL1-B
CL1-B
CL1-B
CL1-B
CL1-B
CL1-B
CL1-B
CL1-B
CL1-B
CL1-B
CL1-B
CL1-B
CL1-B
CL1-B
CL1-B...
Can you help me understand how the populating of dshosts[$2] works...
this is what I understand:
If I have:
DN: castle
DS: disk1
DS: disk2
GI: windows
then
/^DS/ { dshosts[$2]=dshosts[$2]dn" " }
really means
/^DS/ { dshosts[disk1]=disk1castle" " }
/^DS/ { dshosts[disk2]=disk2castle" " }...
So I ended up trying to rearrange the lines so the last line was moved to the first line of each record (separated by GUEST).
It works.. but its long and ugly:
sed -n -e 's/GUEST/Q/p' -e '/^DN/p' -e '/^DS/p' -e '/^GI/p' /tmp/vStorage | awk 'BEGIN{RS="Q"}{print "GI: "$6,$0}'|awk...
One more question that I can't figure out..
There's one more field I'd like to track in the equation..
GUEST
DN: apple
DS: G-WE01-E20A-SLS-4
DS: G-WE01-E203-SLS-4
GI: windows
GUEST
DN: grape
DS: G-WE01-E20B-SLS-4
GI: unix
GUEST
DN: banana
DS: G-WE01-E20A-SLS-4
DS: G-WE01-E200-SLS-4
GI: Solaris...
This is the type of data I'm working with:
GUEST
DN: apple
DS: G-WE01-E20A-SLS-4
DS: G-WE01-E203-SLS-4
GUEST
DN: grape
DS: G-WE01-E20B-SLS-4
GUEST
DN: banana
DS: G-WE01-E20A-SLS-4
DS: G-WE01-E200-SLS-4
I have two records here, the "GUEST" line I can use as my record separator.
Basically I'd...
I have a script that uses several awk one liners to manipulate data. Does it make sense to have several awk programs in one shell script, or is it always possible to combine the awk programs?
Example:
#Running bperror to get data
/usr/openv/netbackup/bin/admincmd/bperror -backstat -l -d...
Wow. Nice. Can you explain what the awk statements are doing?
I understand it up until this point:
...,/Serial Number/?RS:FS}'
I know printf is printing two strings, .. but are you searching for "Serial Number" again? Also what does ?RS:FS do? Record Separater:Field Seperator? Not sure...
I think I figured it out.
.... | awk 'BEGIN { OFMT = "%2.2f" }; {print $2, $12, $13, $14/86400+25569-6/24, $15, $16/86400+25569-6/24, $19, $20}'
If anybody has a better way, let me know.
Thanks
I have a line that looks like this:
Jane likes math 13
My awk program:
awk '{print $1, $2, $3/14}'
Results:
Jane likes 0
Desired:
Jane likes 0.21
I was playing with the printf command but I can't get it to print both numbers and words out.
# echo "40052.96 hello" |awk '{printf...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.