[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: missing way to extract data out of data

From: Dale R. Worley
Subject: Re: missing way to extract data out of data
Date: Thu, 18 Mar 2021 21:02:43 -0400

Alex fxmbsw7 Ratchev <fxmbsw7@gmail.com> writes:
> there is way to crop data to wanted, by cropping the exclulsions away
> but what about a way to extract data, eg @( .. ) match
> not about using [[ =~ but only var internal stuff
> .. or do i miss there something

If you want to do a pattern-match against a string, then extract a part
of it, a common way is to use sed.  For instance, to extract a word and
remove spaces before and after it:

$ STRING='  abc def   '
$ WORD="$( <<<$STRING sed -e 's/^ *\([^ ]*\) *$/\1/' )"
$ echo "$WORD"

It is common to use common Unix utilities to modify data items within
shell scripts.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]