whatskendoing
whatskendoing

Reputation: 11

AWK Filter and then trim output

I am looking to trim the output below

curl -s -L https://www.citrix.com/downloads/workspace-app/mac/workspace-app-for-mac-latest.html#ctx-dl-eula-external | awk '/<p>Version:&nbsp;/ {print $1}' 

    

Current Output: <p>Version:&nbsp;20.08.0.3

Desired Output: 20.08.0.3

Upvotes: 0

Views: 104

Answers (2)

vgersh99
vgersh99

Reputation: 965

curl -s -L https://www.citrix.com/downloads/workspace-app/mac/workspace-app-for-mac-latest.html#ctx-dl-eula-external | awk '{print substr($1,index($1,";")+1)}'

Upvotes: 0

RavinderSingh13
RavinderSingh13

Reputation: 133458

Could you please try following, written and tested with shown samples only.

your_command | awk '
match($0,/<p>Version:&nbsp;([0-9]+\.){3}[0-9]+/){
  val=substr($0,RSTART,RLENGTH)
  sub(/.*;/,"",val)
  print val
  val=""
}'

Upvotes: 1

Related Questions