Character: 12345ABCDE
Split into:
1
2
3
4
5
A
B
C
D
E
Method
echo 12345ABCDE | Awk-f "' {for (i=1;i<=nf;i++) print $i} '
echo 12345ABCDE | Sed ' s/./&n/g '
echo 12345ABCDE | Grep-po '. '
echo "12345ABCDE" | Fold-w1
And then
Please 1000! How many 0 are included in the results? NOTE: 1000! = 1x2x3x4x5x...x999x1000
[Root@node4 ~]# Cat t.sh
#!/bin/bash
Export A=1
For i in ' seq 1 1000 '
Todo
A= ' expr $a * $i '
Done
Echo $a
[root@node4 ~]# sh t.sh | Awk-f "' {for (i=1;i<=nf;i++) ++s[$i]} end{for (i in S) if (i = 0) print i" "s[i]} '
0 472
What about 0 to 9?
[root@node4 ~]# sh t.sh | Awk-f "' {for (i=1;i<=nf;i++) ++s[$i]} end{for (i in S) print I" "s[i]} '
4 229
5 213
6 231
7 217
8 257
9 246
0 472
1 239
2 248
3 216
Query the position of character B in a string
[Root@node4 ~]# cat AA
Dfgsbfrgb
Frgfvregb
B
GrG
Fsdvgbbef
Bfrg
[Root@node4 ~]# awk-f ' {for (i=1;i<=nf;i++) s[i]= $i; for (i in S) if (s[i] = = "B") Print I "S[i" "Row" Nr;delete S} ' Aa
5 B Row 1
9 B Row 1
Ten B Row 2
1 B Row 3
7 B Row 5
1 B Row 6