0

For Example,consider the below line

<WORKFLOWLINK CONDITION ="" FROMTASK ="Start" TOTASK ="cmd_START_RUN"/>

From above line, I need to print Start from FROMTASK ="Start" using grep command or using any command.

Etan Reisner
  • 77,877
  • 8
  • 106
  • 148
pyennamp
  • 11
  • 4
  • 1
    If this is about "parsing" XML then the answer is to use an xml parsing tool. Like perl, python, ruby, etc. or to use a tool like xsltproc or [XMLStarlet](http://xmlstar.sourceforge.net/). – Etan Reisner Dec 16 '14 at 12:31
  • ksh: xmllint: not found. error – pyennamp Dec 16 '14 at 12:55

3 Answers3

3

Try doing this :

$ xmllint --xpath 'string(//WORKFLOWLINK/@FROMTASK)' file
Start

$ xmlstarlet sel -t -v 'string(//WORKFLOWLINK/@FROMTASK)' file
Start

$ saxon-lint --xpath 'string(//WORKFLOWLINK/@FROMTASK)' file
Start
Gilles Quénot
  • 173,512
  • 41
  • 224
  • 223
0

If you just want value of FROMTASK, or some fixed variables try sed:

sed -nre 's/^.*FROMTASK *= *"([^"]*)".*$/\1/p' file

If you want to get value of any variables, try xmllint as sputnick answered

Use sudo apt-get install libxml2-utils(for debian) or yum install libxml2-utils to install it.

Community
  • 1
  • 1
D3Hunter
  • 1,329
  • 10
  • 21
0

Since your tags don't suggest this is about XML, simply use cut command

cut -d "\"" -f4
ppm9
  • 58
  • 4