[Linux] How does a shell script output a string of characters in a file as a variable?

There is a file a.txt
with the content as follows

XXXXXXXXXXXXXX
123456789456123

哈哈哈哈或或或哈

a.txt file XXXXXXXXXXXXXX content is not fixed
if we want to select content a.txt in XXXXXXXXXXXXXX of output variables as a shell script can do so by
1, first a.txt all content files assigned to the variable C
C = $ (CAT a.txt)
2. Then select the character XXXXXXXXXXXXXX you want to get in C, and assign the selected XXXXXXXXXXXXXX content to D
D=$(echo ${C:0:14}) (echo ${C:0:14} The command is to output XXXXXXXXXXXXXX in C)
3. Finally, output
echo $D to XXXXXXXXXXXXXX that you want to output

Guess you like

Origin blog.csdn.net/qq_44065303/article/details/109025766