-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsplit.sh
More file actions
33 lines (28 loc) · 747 Bytes
/
split.sh
File metadata and controls
33 lines (28 loc) · 747 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash
#-----------------------------------------------------
# Arquivo: split.sh
# Descricao: Like a strtok or split
# Split string into tokens
#
# Autor: Paulo Tovo
# Data: 23/06/2018
#-----------------------------------------------------
echo " *** "
echo " *** Split string into tokens in Shell Script "
echo " *** "
strvar="192.168.0.1"
echo " *** String: $strvar"
echo " *** Delimiter: ."
tokens=( ${strvar//[.]/ } )
echo " *** Number of extracted tokens: ${#tokens[@]} "
i=0
strToken=""
while [ $i != ${#tokens[@]} ]
do
strToken=${tokens[$i]}
echo " *** Token: $strToken"
i=$((i+1))
done
echo " *** "
echo " *** Operation completed successfully. "
echo " *** "