0

I have ~ 60K bibliographic records, which can be identified by system number. These records also hold full-text (individudal text files named by system number).

I have lists of system numbers in bunches of 5K and I need to find a way to copy only the text files from each 5K list. All text files are stored in a directory (/fulltext) and are named something along these lines: 014776324.txt.

The 5k lists are plain text stored in separated directories (e.g. /5k_list_1, 5k_list_2, ...), where each system number matches to a .txt file.

For example: bibliographic record 014776324 matches to 014776324.txt.

I am struggling to find a way to copy into the 5k_list_* folders only the corresponding text files.

Any idea?

Thanks indeed,

4

1 回答 1

1

假设我们以这种方式调用以下脚本:

./the-script.sh fulltext 5k_list_1 5k_list_2 [...]

或者更简洁地说:

./the-script.sh fulltext 5k_list_*

然后尝试使用这个(完全未经测试的)脚本:

#!/usr/bin/env bash
set -eu # enable error checking

src_dir=$1 # first argument is where to copy files from
shift 1

for list_dir; do # implicitly consumes remaining args
    while read bibliographic record sys_num rest; do
        cp "$src_dir/$sys_num.txt" "$list_dir/"
    done < "$list_dir/list.txt"
done
于 2013-07-02T11:20:26.843 回答