There are a lot of ways. First question: Why do you want the index? Stop and think about what you want to use it for, and maybe you can go directly to the need instead of by steps. Do you want everything to the left (or right) of the ':'? leftpart=$(echo $first | cut -f 1 -d ':')rightpart=$(echo $first | cut -f 2 -d ':') Do you want to split it into pieces and handle them individually?
for part in $(echo $first|tr ':' ' ') ; do
You can also try to use the ternary operator if you use a recent bash shell, but I've been having trouble finding a good example. I also often use awk (gawk for the gnu version) which is pretty arcane, but quite useful. Or step up to Python or perl?
Can u help me out..I want to make some tables and give some querries in mysql. And I want to automate this... So can someone help me to write a script which will do all this....
It should open mysql....put in the password and must be able to type something in it.