Operating System - Linux
1753971 Members
7953 Online
108811 Solutions
New Discussion юеВ

Extract 4 first string's characters

 
SOLVED
Go to solution
Leo The Cat
Regular Advisor

Extract 4 first string's characters

Hi All

How to extract the 4 first characters like this.

S=abcdefghi....
result: abcd

Bests regards
Den
2 REPLIES 2
Ivan Ferreira
Honored Contributor
Solution

Re: Extract 4 first string's characters

# S=abcdefghi
# STRIP=$( echo $S | cut -c 1-4)
# echo $STRIP
abcd
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Leo The Cat
Regular Advisor

Re: Extract 4 first string's characters

Thanks Ivan. Very perfect !