Re: Problem with positional output
| Newsgroups | gmane.editors.sed.user |
|---|---|
| Message-ID | <[email protected]> |
On 2016-11-14 15:20, Sven Guckes [email protected] [sed-users] wrote: > * SED Users <[email protected]> [2016-11-14 14:36]: > > On 2016-11-14 14:03:50 Michelle Konzack hacked into the keyboard: > > > ..I have forgotten ho to get values from a string... > > > The string has 4 parameters, seperated by the | sign > > > and I like to get it with something like > > > echo "${RETVAL}" |sed 's!(.*)|(.*)|(.*)!$1!' > > This is now working with: > > echo "${RETVAL}" |sed 's!\(.*\)|\(.*\)|\(.*\)!\1!' > > hmm.. > so you basically want just the bginning of the data > and discard everything from the first pipe sign? > > here is what i'd do in z-shell: > > zsh> DATA='one|two|three|four' > zsh> echo ${DATA%%|*} > one Sven's suggestion also works in bash and dash shells. -tkc