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

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -