I have a variable storing "ping_abc", how do I remove the "ping_" part to get just "abc"?
My approach: variable 'test' stores "ping_abc"
I tried:
echo ${test:0:4}
But this is giving me:
Bad : modifier in $ (4), error
Approach on suggested answer by @Yaron:
set test = "ping_abc"
echo test | awk -F_ '{print $2}'
echo ping_abc | awk -F_ '{print $2}'
o/p:
//blankspace
abc
Why does the test variable not get truncated?
bash
andtcsh
. fortcsh
you should use the following: echo ping_abc | awk -F_ '{print $2}' – Yaron Mar 06 '17 at 13:33