How to break a string into words & store the words in separate variables
like
name1="aaa"
name2="abcd"
name..
.
.
using shell script?
See this post on substring and search the forums for other examples.
bash:
file=/dir1/dir2/dir3/my.file.txt
${file#*/} #dir1/dir2/dir3/my.file.txt
${file##*/} #my.file.txt
${file#*.} #file.txt
${file##*.} #txt
${file%/*} #/dir1/dir2/dir3
${file%.*} #/dir1/dir2/dir3/my.file
${file%%.*} #/dir1/dir2/dir3/my
${file:1:4} #dir1
Cheers, try yourself.
Bash...
$ phrase="aaa bbb ..."
$ arr=($phrase)
$ echo ${arr[0]}
aaa
$ echo ${arr[1]}
bbb
$ echo ${#arr[*]}
3