Skip to content

blasphemy.sh is an xml parser written in bash for people who are violently forced to parse xml in a shell script.

Notifications You must be signed in to change notification settings

RobinRamael/blasphemy.sh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 

Repository files navigation

blasphemy.sh

blasphemy.sh is an xml parser written in bash for people who are violently forced to parse xml in a shell script.

Usage

Always read the blasphemy.sh file in first.

source blasphemy.sh

get_elements returns all children of the root with the given name. Return all elements with the tag "book":

cat examples/books.xml | get_elements book

Search for attributes with search_attr and search_content, use --like or -l for partial search:

cat examples/books.xml | get_elements book | search_attr book id bk111
# searches for books with the id attribute set to bk111

cat examples/books.xml | get_elements book | search_content --like description XML
# searches for all books that have "XML" int their description.

You can pipe all these:

cat examples/books.xml | get_elements book | \
search_content --like description XML | \
search_content author "O'Brien, Tim" | get_elements publish_date
# get all books with "XML" in their description and by Tim O'Brien.

After all that, you can strip the tags with get_content:

cat examples/books.xml | get_elements book |\
search_attr book id bk111 | get_elements title | get_content 

About

blasphemy.sh is an xml parser written in bash for people who are violently forced to parse xml in a shell script.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages