Omnimaga
General Discussion => Technology and Development => Computer Usage and Setup Help => Topic started by: Hayleia on December 07, 2013, 11:54:46 am
-
First of all, what does "last part" mean ? It means "all characters after some special character". For example, if that character is "-", then the "last part" of "1574-114687-415" is "415" and the "last part" of "jg7e;f,k-e" is "e".
So, yeah, how do I extract the "last part" of a string (you can provide examples with the "-") ?
edit that's surely not informative, but I am using Ubuntu 13.04
-
Question: Is this supposed to be solved using shell scripts only?
-
I did this using sed, a stream editor.
echo "1574-114687-415" | sed s/.*-//
will replace everything at the beginning of a string that has a - at the end with nothing, and continue on in this way. It returns everything which doesn't have a - after it.
-
Question: Is this supposed to be solved using shell scripts only?
Yes.
I did this using sed, a stream editor. echo "1574-114687-415" | sed s/.*-//
will replace everything at the beginning of a string that has a - at the end with nothing, and continue on in this way. It returns everything which doesn't have a - after it.
Thanks, that works great :D