bash - Extract number from first line of a file in linux -
i have file has contents below
spec.2.attrid=revision& spec.2.value=5& spec.3.attrid=num& spec.3.value=vs&
i using below command extract numbers first line. way efficient or guys think of alternate way ?
cat ticketspecdata | tr -d " " | tr -s "[:alpha:]" "~" | tr -d "[=.=]" | cut -d "~" -f2
using grep :
$ grep -om1 '[0-9]\+' file 2
Comments
Post a Comment