root/bin/import_name @ 7612
1 | 6104 | aaronmk | #!/bin/sh
|
---|---|---|---|
2 | # Gets the name of an import based on its log file names
|
||
3 | # Usage: self logs...
|
||
4 | |||
5 | sedEreFlag="$(test "$(uname)" = Darwin && echo E || echo r)" |
||
6 | |||
7 | sed () { "$(which sed)" -"$sedEreFlag" "$@";} |
||
8 | |||
9 | if ! test "$#" -ge 1; then |
||
10 | echo "Usage: self logs..."|fold -s >&2 |
||
11 | exit 2
|
||
12 | fi
|
||
13 | |||
14 | for log in "$@"; do |
||
15 | echo "$log"|sed -n 's/^.*\/logs\/(.*)\.log\.sql$/\1/p' |
||
16 | break # only for first log file |
||
17 | done
|