Sponsored Content
Top Forums Shell Programming and Scripting Parsing file, yaml file? Extracting specific sections Post 302279450 by vgersh99 on Thursday 22nd of January 2009 05:36:21 PM
Old 01-22-2009
something along these lines - assuming ''somedomain-s' are indented with spaces.

nawk -f rh.awk myYAMLfile

rh:awk:
Code:
BEGIN {
   FS=RS=""
}
$1 == "addon_domains:"{
   for(i=2; $i ~ /^  */; i++)
      print substr($i, 1, index($i, ":")-1)
}

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Parsing file and extracting the useful data block

Greetings All!! I have a very peculiar problem where I have to parse a big text file and extract useful data out of it with starting and ending block pattern matching. e.g. I have a input file like this: sample data block1 sample data start useful data end sample data block2 sample... (5 Replies)
Discussion started by: arminder
5 Replies

2. UNIX for Dummies Questions & Answers

Is extracting specific files from a zip file possible?

If a zip file contains several zip files, but if the file names of the files needed are known, is there a variation of the unzip command that will allow those few (individual) files to be extracted? --- Example: Zip file name: zip.zip unzip -l zip.zip will display file01, file02, file03, etc.... (1 Reply)
Discussion started by: HLee1981
1 Replies

3. Programming

problems iterating in RUBY while extracting info from YAML, Pls help!

Hi all, I am stuck with a ruby script that extracts detials from yaml file and processes accordingly. the yaml file confivnic: device: vnic1: policy: - L2 mode: active vnic2: policy: - L3 - L4 mode: active type: aggr ... (1 Reply)
Discussion started by: wrapster
1 Replies

4. Shell Programming and Scripting

Extracting specific text from a file

Dear All, I have to extract a a few lines from a log file and I know the starting String and end string(WHich is same ). Is there any simplere way using sed - awk. e.g. from the following file -------------------------------------- Some text Date: 21 Oct 2008 Text to be extracted... (8 Replies)
Discussion started by: rahulkav
8 Replies

5. Shell Programming and Scripting

SED 4.1.4 - INI File Change Problem in Variables= in Specific [Sections] (Guru Help)

GNU sed version 4.1.4 on Windows XP SP3 from GnuWin32 I think that I've come across a seemingly simple text file change problem on a INI formatted file that I can't do with SED without side effects edge cases biting me. I've tried to think of various ways of doing this elegantly and quickly... (5 Replies)
Discussion started by: JakFrost
5 Replies

6. Shell Programming and Scripting

extracting specific lines from a file

hi all, i searched in unix.com and accquired the following commands for extracting specific lines from a file .. sed -n '16482,16482p' in.sql > out.sql awk 'NR>=10&&NR<=20' in.sql > out.sql.... these commands are working fine if i give the line numbers as such .. but if i pass a... (2 Replies)
Discussion started by: sais
2 Replies

7. Shell Programming and Scripting

Extracting content from a file in specific format

Hi All, I have the file in this format **** Results Data **** Time or Step 1 2 20 0.000000000e+00 0s 0s 0s 1.024000000e+00 Us 0s 0s 1.100000000e+00 1s 0s 0s 1.100000001e+00 1s 0s 1s 2.024000000e+00 Us Us 1s 2.024000001e+00 ... (7 Replies)
Discussion started by: diehard
7 Replies

8. UNIX for Advanced & Expert Users

Extracting specific lines from data file

Hello, Is there a quick awk one-liner for this extraction?: file1 49389 text55 52211 text66 file2 59302 text1 49389 text2 85939 text3 52211 text4 13948 text5 Desired output 49389 text2 52211 text4 Thanks!! (5 Replies)
Discussion started by: palex
5 Replies

9. Shell Programming and Scripting

YAML file update

removing post since it got fix (1 Reply)
Discussion started by: kishore150
1 Replies

10. UNIX for Dummies Questions & Answers

Help on parsing Oracle RMAN output for string and print sections of a file

Hi, I need some advise on how to print 'sections' of the attached file. I am searching for some that says Marked Corrupt and print some lines after it. At the moment I am running the command below: sed -n -e '/Marked Corrupt/{N;N;p;}' rman_list_validate.txtThis gives me the following... (1 Reply)
Discussion started by: newbie_01
1 Replies
yaml(n) 							  YAML processing							   yaml(n)

__________________________________________________________________________________________________________________________________________________

NAME
yaml - YAML Format Encoder/Decoder SYNOPSIS
package require Tcl 8.4 package require yaml ?0.3.3? ::yaml::yaml2dict ?options? txt ::yaml::yaml2huddle ?options? txt ::yaml::setOption ?options? ::yaml::dict2yaml dict ?indent? ?wordwrap? ::yaml::list2yaml list ?indent? ?wordwrap? ::yaml::huddle2yaml huddle ?indent? ?wordwrap? _________________________________________________________________ DESCRIPTION
The yaml package provides a simple Tcl-only library for parsing the YAML http://www.yaml.org/ data exchange format as specified in http://www.yaml.org/spec/1.1/. The yaml package returns data as a Tcl dict. Either the dict package or Tcl 8.5 is required for use. COMMANDS
::yaml::yaml2dict ?options? txt ::yaml::yaml2huddle ?options? txt Parse yaml formatted text txt into a Tcl dict/huddle and return the value. -file txt is a filename of YAML-stream. -stream txt is just a YAML-stream. -types list The list is a type list for the yaml-scalar types.(e.g. !!str !!timestamp !!integer !!true ...) -types {timestamp integer null true false} In this case, if a string matched "timestamp", converted to the TCL internal timestamp.(e.g. "2001-12-15T02:59:43.1Z" => 1008385183) -m:true param The param is two elements of list for the value of true, and considered strings. -m:true {1 {true on + yes y}} In this case, the string "yes" found in YAML Stream, automatically converted 1. -m:false param The param is two elements of list for the value of false, and considered strings. -m:false {0 {false off - no n}} -m:null param The param is two elements of list for the value of null, and considered strings. -m:null {"" {null nil "" ~}} -validate Experiment,old: Output stream contains YAML's-tag, each node. % puts [::yaml::load -validate {[aaa, bbb]}] => !!seq {{!!str aaa} {!!str bbb}} ::yaml::setOption ?options? Change implicit options for the library. Now, the params are the same as ::yaml::yaml2dict. Arguments of::yaml::yaml2dict is more priority than this setting. ::yaml::dict2yaml dict ?indent? ?wordwrap? ::yaml::list2yaml list ?indent? ?wordwrap? ::yaml::huddle2yaml huddle ?indent? ?wordwrap? Convert a dict/list/huddle object into YAML stream. indent spaces indent of each block node. currently default is 2. wordwrap word wrap for YAML stream. currently default is 40. EXAMPLES
An example of a yaml stream converted to Tcl. A yaml stream is returned as a single item with multiple elements. { --- !<tag:clarkevans.com,2002:invoice> invoice: 34843 date : 2001-01-23 bill-to: &id001 given : Chris family : Dumars address: lines: | 458 Walkman Dr. Suite #292 city : Royal Oak state : MI postal : 48046 ship-to: *id001 product: - sku : BL394D quantity : 4 description : Basketball price : 450.00 - sku : BL4438H quantity : 1 description : Super Hoop price : 2392.00 tax : 251.42 total: 4443.52 comments: Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338. } => invoice 34843 date 2001-01-23 bill-to {given Chris family Dumars address {lines {458 Walkman Dr. Suite #292 } city {Royal Oak} state MI postal 48046}} ship-to {given Chris family Dumars address {lines {458 Walkman Dr. Suite #292 } city {Royal Oak} state MI postal 48046}} product {{sku BL394D quantity 4 description Basketball price 450.00} {sku BL4438H quantity 1 description {Super Hoop} price 2392.00}} tax 251.42 total 4443.52 comments {Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338.} An example of a yaml object converted to Tcl. A yaml object is returned as a multi-element list (a dict). { --- - [name , hr, avg ] - [Mark McGwire, 65, 0.278] - [Sammy Sosa , 63, 0.288] - Mark McGwire: {hr: 65, avg: 0.278} Sammy Sosa: { hr: 63, avg: 0.288} } => {name hr avg} {{Mark McGwire} 65 0.278} {{Sammy Sosa} 63 0.288} {{Mark McGwire} {hr 65 avg 0.278} {Sammy Sosa} {hr 63 avg 0.288}} LIMITATIONS
tag parser not implemented. currentry, tags are merely ignored. Only Anchor => Aliases ordering. back alias-referring is not supported. Too many braces, or too few braces. Not enough character set of line feeds. Please use only " " as line breaks. BUGS, IDEAS, FEEDBACK This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category yaml of the Tcllib SF Trackers [http://sourceforge.net/tracker/?group_id=12883]. Please also report any ideas for enhancements you may have for either package and/or documentation. SEE ALSO
base64, huddle, json KEYWORDS
data exchange, huddle, parsing, text processing, yaml COPYRIGHT
Copyright (c) 2008 KATO Kanryu <kanryu6@users.sourceforge.net> yaml 0.3.3 yaml(n)
All times are GMT -4. The time now is 10:27 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy