-1

Example I have ver.txt

#tac
version=xxx

I want to display only xxx.

I can try grep, sed, gawk.Just want to learn how to make it.

  • I didn't try something special.Found http://stackoverflow.com/questions/1247812/im-stuck-in-trying-to-grep-anything-just-after-name few solutions there.They were for linux.Anyways tried all of them but not working. – KaptaPrism Oct 05 '13 at 14:00

2 Answers2

2

One of many ways is to use grep interpreting the pattern as a perl regular expression, and use a positive look-behind:

grep -oP '(?<=version=).*' infile
Birei
  • 35,723
  • 2
  • 77
  • 82
1

the awk answer:

awk -F = '$1=="version" {print $2}' file

Sed

sed -n '/^version=/s///p' file

If you are running these commands from a windows command prompt, then single quote is not a valid grouping character, you may have to do this

awk -F = "$1==\"version\" {print $2}" file
glenn jackman
  • 238,783
  • 38
  • 220
  • 352