| Newsgroups |
gmane.editors.sed.user |
| Message-ID |
<[email protected]> |
Yes, an example usually helps, prevents misinterpretation. I tried to
provide one:
$ cat example.txt
param 1|param 2|param 3|param 4
The suggested sed solution does not work correctly, as the first .* is
greedy and gobbles up the first '|' character:
$ sed 's!\(.*\)|\(.*\)|\(.*\)!\1!' example.txt
param 1|param 2
Adding one more 'hold pattern' works correctly, I think.
$ sed 's!\(.*\)|\(.*\)|\(.*\)|\(.*\)!\1!' example.txt
param 1
Instead of .* one could also use [^|]* expression.
Daniel
On 11/14/2016 6:20 AM, 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
>
> an example would be nice to see whether
> we are talking about the same thing. ;)
>
> Sven
>
>
> ------------------------------------
> Posted by: Sven Guckes <[email protected]>
> ------------------------------------
>
------------------------------------
------------------------------------
--
------------------------------------
Yahoo Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/sed-users/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/sed-users/join
(Yahoo! ID required)
<*> To change settings via email:
[email protected]
[email protected]
<*> To unsubscribe from this group, send an email to:
[email protected]
<*> Your use of Yahoo Groups is subject to:
https://info.yahoo.com/legal/us/yahoo/utos/terms/