Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- string=(0 10 20 30 40)
- add_string=(10 5 35 45 50)
- for A in ${add_string[@]}; do
- SAME=0
- max=0
- for S in ${string[@]}; do
- if [ "$A" = "$S" ]; then
- SAME=1
- shift
- fi
- if [ "$A" -gt "$S" ]; then
- max=$(($max + 1))
- fi
- done
- if [ "$SAME" = 0 ]; then
- newstring=(${string[@]:0:$max} $A ${string[@]:$max})
- string=(${newstring[@]})
- fi
- done
- echo ${string[@]}
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement