I would like to split a string into two halves and print them sequentially. For example:
abcdef
into
abc
def
Is there a simple way to do it, or it needs some string processing?
bashstring
I would like to split a string into two halves and print them sequentially. For example:
abcdef
into
abc
def
Is there a simple way to do it, or it needs some string processing?
Best Answer
Using parameter expansion and shell arithmetic:
The first half of the variable will be:
The second half of the variable will be:
so you could use:
You could also use the following awk command: