Array and check strings
I have array like fileArray=(AB CD EF GH END,4 IJ KL END,7)
Now i want outputarray like this (AB CD EF GH IJ KL) Means if array contents start with END then delete that content. I tried this by fileArray=($fileArray[@]#END) But it gives output fileArray=(AB CD EF GH ,4 IJ KL ,7) How can i check this |
Close:
Code:
fileArray=(${fileArray[@]##END*}) |
how can i retrieve indexnumber of all the strings which are starting from "END"
|
Code:
#!/bin/bash |
Code:
#!/bin/bash |
I am not able to understand this stmt :--
[[ "${fileArray[i]}" =~ ^END ]] Can you please elaborate this :- Is above stmt. a syntax corresponding to if condition? I used if like this :- if test $1 -gt 0 then echo "$1 number is positive" else echo "$1 number is negative" fi |
Quote:
[[]] - are test brackets and yes they act like an if whereby followed by && means do the next bit if test is true or followed by || means do the next bit if false |
All times are GMT -5. The time now is 06:42 AM. |