-
Notifications
You must be signed in to change notification settings - Fork 0
/
getrecord
executable file
·45 lines (37 loc) · 973 Bytes
/
getrecord
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#! /bin/bash
# getrecord
# Get specific record(s) from larger file of marc records.
# $Id: getrecord
E_BADARGS=65
scriptdir=$( (cd -P $(dirname $0) && pwd) )
#define the function
find_newest_file_matching_pattern_under_directory(){
echo $(find $1 -maxdepth 1 -name "$2" -print0 | xargs -0 ls -1 -t | head -1)
}
marc4j_jar=$( find_newest_file_matching_pattern_under_directory $scriptdir "marc4j*.jar" )
if ! [ -p /dev/stdin ]
then
if [ $# -eq 0 ]
then
echo " Usage: `basename $0` ./path/to/marcfile.mrc regex_of_ids_to_extract"
echo " Usage: `basename $0` ./path/to/marcfile.mrc -h field_that_must_be_present"
echo " Usage: `basename $0` ./path/to/marcfile.mrc file_with_list_of_ids.txt"
exit $E_BADARGS
fi
arg1=$1
arg2=$2
arg3=$3
arg4=$4
arg5=$5
arg6=$6
else
arg1=-
arg2=$1
arg3=$2
arg4=$3
arg5=$4
arg6=$5
arg7=$6
fi
java -jar $marc4j_jar getrecord $arg1 $arg2 $arg3 $arg4 $arg5 $arg6 $arg7
exit 0