Mar 15, 2002 #1 umeman Technical User Oct 2, 2001 59 US How do I get a subtring in a UNIX Korn shell script: STRING1='ABCD01' I want to assign STRING2='ABCD' derived from STRING1 Any help appreciated -u-
How do I get a subtring in a UNIX Korn shell script: STRING1='ABCD01' I want to assign STRING2='ABCD' derived from STRING1 Any help appreciated -u-
Mar 15, 2002 #2 grega Programmer Feb 2, 2000 932 GB You could do ... STRING1='ABCD01' STRING2=$(echo $STRING1 | cut -c1-4) Greg. Upvote 0 Downvote
Mar 15, 2002 #3 olded Programmer Oct 27, 1998 1,065 US umeman: I like greg's solution better, but .... string1="ABCD01" string2=$(echo $string1|awk ' { print substr($0, 1, 4) } ') echo $string2 Regards, Ed Schaefer Upvote 0 Downvote
umeman: I like greg's solution better, but .... string1="ABCD01" string2=$(echo $string1|awk ' { print substr($0, 1, 4) } ') echo $string2 Regards, Ed Schaefer