0

How can I get the output below using shell commands?

Input as below:

Nexus-test-1.12.3
Producer-1.13.3
Testing-one-word-1.12

Output should be

Nexus-test
Producer
Testing-one-word
Anusha M
  • 51
  • 1
  • 1
  • 6

2 Answers2

1

I really struggle with whether or not to answer this, because it's incredibly trivial and it appears that zero effort has been made to figure it out. But....just do:

cut -d . -f 1
William Pursell
  • 204,365
  • 48
  • 270
  • 300
1

There are many ways to do it, hope you can do a search first.

awk:

awk -F'.' '{$0=$1}7'

sed:

sed 's/[.]*//'

grep:

grep -Po '^[^.]*'
Kent
  • 189,393
  • 32
  • 233
  • 301