- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Hail sed gurus
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2002 09:16 PM
01-31-2002 09:16 PM
Hail sed gurus
1. /var/opt/OV/conf/OpC/le
2. /var/opt/OV/conf/OpC/monitor
3. /var/opt/OV/conf/OpC/msgi
4. /var/opt/OV/conf/OpC/trapi
(not necessarily required to know if you don't have ITO or variant apart from knowing output of this).
Output produces multiple fields ($1) and field value "$2"
Example Output:
FIELD1 "value of some type"
FIELD2 "whatever"
FIELD3 "something else"
(indents are varied but still conform to $1 $2)
This output is particularly easy to work with. Unfotunately as per usual, some output from opcdcode is a little rogue in that for some particular fields, the "value" is found on the following line.
Example Output:
FIELD1 "value of some type"
FIELD2 "whatever"
FIELD3
"something else"
(indents are varied but still last line, the expected $2 becomes a $1)
I know there is a simple sed solution.
I am looking for a sed (or sed/awk combo) that will join any line in which the first non space characted is a non letter (i.e. above the first character is "), with the line preceding.
In effect making turning
FIELD1 "X"
FIELD2 "X"
FIELD3
"X"
FIELD4 "X"
FIELD5
"X"
into
FIELD1 "X"
FIELD2 "X"
FIELD3 "X"
FIELD4 "X"
FIELD5 "X"
Any help much appreciated and rewarded
Glenn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2002 01:21 AM
02-01-2002 01:21 AM
Re: Hail sed gurus
If the file is not too long and each line starts with field try
echo $(cat outputfile)|sed -e 's/FIELD/\^JFIELD/g'
^j is formed by cntrlVcntrlM
Steve Steel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2002 01:56 AM
02-01-2002 01:56 AM
Re: Hail sed gurus
awk 'BEGIN {RS="";a=1;b=2} {while (a < NF) {print $'a'" "$'b';a+=1;b+=1} }' inputfile
Grtz.
Vincent
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2002 02:22 AM
02-01-2002 02:22 AM
Re: Hail sed gurus
Create an awk script containing:
BEGIN{FS=""}
$1 !~ "[a-zA-Z]"{printf(" %s",$0);next}
{printf("%s%s"),s,$0;s="\n"}
END{print}
then run with
awk -f scriptname filename
Rgds, Robin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2002 03:16 AM
02-01-2002 03:16 AM
Re: Hail sed gurus
awk ' NF == 2 { print $1 .... ; next}
NF == 1 { last=$0; getline; print last, $0 }'
### NF -> number of fields
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2002 10:43 PM
02-03-2002 10:43 PM
Re: Hail sed gurus
I've attached the four text files in question.
Namely:
le, monitor, msgi and trapi (not as important)
The monitor file seems okay; all fields are short enough to remain on the same line.
That doesn't mean that in the future this file will always remain this way.
So, running the following command on the other three files, will highlight the entries not conforming to my script - hence requiring a sed/awk fix.
# cat le | awk '{print $1}' | grep -v ^[A-Z] | sort | uniq
Attaching the input, will help you all in providing me a suitable solution.
I will certainly reward 10 points for each and every solution, even if it is solved by a previous user. It's the least I can do for any help provided.
The smaller the solution, the better.
Explaining my logic in using the command above:
The file has varying tabs before $1. Therefore the awk portion eliminates this. The Fields (always starting with A-Z), are then removed by the grep, leaving values that should be joined with the previous line.
For example, in file msgi, the first occurance of "20m":
As per file (indents exist before each line but are taken out by this website).
SUPP_DUPL_IDENT
"20m" RESEND "1d"
Should instead read
SUPP_DUPL_IDENT "20m"
RESEND "1d"
In format
FIELD "Value value value"
Please note, that not all incorrect values start with "
The file trapi is a good example.
CONDITION
$e ".1.3.6.1.4.1.11.2.17.1"
$G 6
$S 58916865
trapi is certainly a harder one to tackle, and might need a varied solution because of format:
FIELD1
SUB_FIELD1 "Value"
SUB_FIELD2 "Value"
I might write something to output this in format.
FIELD1 SUB_FIELD1 "Value"
FIELD1 SUB FILED2 "Value"
Anyway....
Any help mainly on the " values being on the wrong line in le and msgi would be most helpful
Thanks heaps in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2002 12:04 AM
02-04-2002 12:04 AM
Re: Hail sed gurus
Can you please check the attachment, I can't get to it.
Rgds, Robin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2002 12:21 AM
02-04-2002 12:21 AM
Re: Hail sed gurus
Having trouble getting to the attachment myself.
I'll re-attach it when I get back to work tomorrow morning (currently late Monday afternoon in Sydney)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2002 01:19 AM
02-04-2002 01:19 AM
Re: Hail sed gurus
Off topic - my son's there at the moment, he's just mailed me to say it's raining harder than he's ever seen before!! - hope you're not getting flooded...Robin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2002 02:30 PM
02-04-2002 02:30 PM
Re: Hail sed gurus
What's your son doing in Sydney?
Anyway...
I've attached the file again.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2002 02:31 PM
02-04-2002 02:31 PM
Re: Hail sed gurus
I can't understand why. Take 3.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2002 02:35 PM
02-04-2002 02:35 PM
Re: Hail sed gurus
I'll put in a call through the response centre. We're always concerned about the response time from Australia of itrc. At least this is something else along the performance line that I can at least inform the itrc folks about.
If you wish, I can email the file to whomever wants to attempt this tricky problem.
Feel free to email mail - glenn@inodes.net
Thanks