Here is a LIST:
List = "abcd 1234 jvm something"
How to get the second element "1234" without looping all the list?
no spaces between equal sign
$ List="abcd 1234 jvm something"
$ set -- $List
$ echo $2
1234
Some other ways, although not as efficient as using shell's internals
$ echo $List | cut -d" " -f2
1234
$ echo $List | awk '{print $2}'
1234
$ echo $List | sed 's/^.[^ \t]* //;s/ .*//'
1234
$ echo $List | tr " " "\n"|sed -n '2p'
1234
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments