shell - Bash: Spliting string based on some delimiter and storing each in a variable -
113050050/cs101/mysql_java.pdf
the above string, stored in variable 'line'
line="113050050/cs101/mysql_java.pdf"
now want split $line
based on delimiter /
, store each single part in variable
var1=113050050 var2=cs101 var3=mysql_java.pdf
$ ifs=/ read var1 var2 var3 <<< "$line"
results
$ echo $var1 113050050 $ echo $var2 cs101 $ echo $var3 mysql_java.pdf
Comments
Post a Comment