Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- base='hoge_base.txt'
- files=('hoge2.txt' 'hoge3.txt')
- temp1=$(mktemp)
- temp2=$(mktemp)
- trap 'rm -f "${temp1}" "${temp2}"' ERR EXIT
- cp "${base}" "${temp1}"
- for ((i = 0; i < ${#files[@]}; ++i)); do
- if ((i % 2 == 0)); then
- join -o auto -a1 -e '---' "${temp1}" "${files[$i]}" >"${temp2}"
- else
- join -o auto -a1 -e '---' "${temp2}" "${files[$i]}" >"${temp1}"
- fi
- done
- if ((${#files[@]} % 2 == 1)); then
- cat "${temp2}"
- else
- cat "${temp1}"
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement