Remove part of a string using KornShell

I have this string DFUB1AG.T1310LC.C140206.XIYG000.FCIPHE31 and I need to remove the first part of it. How can I do this?

As has been asked here is what I want to achieve.

Want to get this string that is separated by "."

DFUB1AG.T1310LC.C140206.XIYG000.FCIPHE31

And want to remove the first part of it to get the result as below

T1310LC.C140206.XIYG000.FCIPHE31

I have already achieved it by doing this way:

Okay guys I got it done by doing this.

# var=DFUB1AG.T1310LC.C140206.XIYG000.FCIPHE31
# var=${var#*.}
# echo $var
# T1310LC.C140206.XIYG000.FCIPHE31

Upvotes: 1

Views: 2926

Answers (2)

NeronLeVelu
NeronLeVelu

Reputation: 10039

echo "$VarWithYourString" | sed "s/^[^.]\{1,\}./"

or

sed "s/^[^.]\{1,\}./" YourFileInput

Upvotes: 0

James Gawron
James Gawron

Reputation: 969

If STRING is your variable, and you want to strip everything before first dot you can say STRING=${STRING#*.} ........Removes shortest match at beginning of string of any character followed by a dot.

Upvotes: 2

Related Questions