Shell-Script

根據名稱將長文件列表排序到多個子目錄中

  • January 31, 2022

我有一組 1000 多個文件,這些文件/home/dir/dir2/oldspot使用以下格式的文件夾中的文本和日期進行標記:

2020 年 1 月 7 日 23:08 海拔 5 拍攝的文件是

aaaaaa-bbbb-cc10dddd-L1-202007012308-05.std
aaaaaa-bbbb-cc10dddd-L1-"year""month""date""hour""minute"-"elevation".std

在 02/07/2020 01:48 拍攝的文件參考文件是

aaaaaa-bbbb-cc10dddd-L1-202007020148.ref

我想創建一個 bash 腳本,它可以根據匹配時間將所有文件排序到子目錄中/home/dir1/yearmonthdayhour(格式見上文),然後按高度排序到/home/dir/yearmonthdayhour/elevation. 我創建了一個,但它不是很自動化(即對許多 mkdir 和 cp)

在海拔 05 的 2020070123 上獲取的所有數據都將進入 /home/dir/2020070123/2020070123-05.std 的子目錄

/home/dir/2020070123/2020070123-05.std 的內容將是:

aaaaaa-bbbb-cc10-dddd-L1-202007012308-05.std
aaaaaa-bbbb-cc10-dddd-L1-202007012319-05.std
aaaaaa-bbbb-cc10-dddd-L1-202007012331-05.std
aaaaaa-bbbb-cc10-dddd-L1-202007012342-05.std
aaaaaa-bbbb-cc10-dddd-L1-202007012354-05.std

我在這裡包含了七個小時的數據(字元限制了我)。總數據從 01/07/2020 11:31 (202007011131) 到 02/07/2020 08:32 (202007020832) 有 12 個文件,時間戳相隔大約 12-25 分鐘。


aaaaaa-bbbb-cc10dddd-L1-202007012004-00.std
aaaaaa-bbbb-cc10dddd-L1-202007012004-01.std
aaaaaa-bbbb-cc10dddd-L1-202007012004-02.std
aaaaaa-bbbb-cc10dddd-L1-202007012004-03.std
aaaaaa-bbbb-cc10dddd-L1-202007012004-04.std
aaaaaa-bbbb-cc10dddd-L1-202007012004-05.std
aaaaaa-bbbb-cc10dddd-L1-202007012004-06.std
aaaaaa-bbbb-cc10dddd-L1-202007012004-07.std
aaaaaa-bbbb-cc10dddd-L1-202007012004-08.std
aaaaaa-bbbb-cc10dddd-L1-202007012004-09.std
aaaaaa-bbbb-cc10dddd-L1-202007012004-10.std
aaaaaa-bbbb-cc10dddd-L1-202007012004.ref
aaaaaa-bbbb-cc10dddd-L1-202007012016-00.std
aaaaaa-bbbb-cc10dddd-L1-202007012016-01.std
aaaaaa-bbbb-cc10dddd-L1-202007012016-02.std
aaaaaa-bbbb-cc10dddd-L1-202007012016-03.std
aaaaaa-bbbb-cc10dddd-L1-202007012016-04.std
aaaaaa-bbbb-cc10dddd-L1-202007012016-05.std
aaaaaa-bbbb-cc10dddd-L1-202007012016-06.std
aaaaaa-bbbb-cc10dddd-L1-202007012016-07.std
aaaaaa-bbbb-cc10dddd-L1-202007012016-08.std
aaaaaa-bbbb-cc10dddd-L1-202007012016-09.std
aaaaaa-bbbb-cc10dddd-L1-202007012016-10.std
aaaaaa-bbbb-cc10dddd-L1-202007012016.ref
aaaaaa-bbbb-cc10dddd-L1-202007012027-00.std
aaaaaa-bbbb-cc10dddd-L1-202007012027-01.std
aaaaaa-bbbb-cc10dddd-L1-202007012027-02.std
aaaaaa-bbbb-cc10dddd-L1-202007012027-03.std
aaaaaa-bbbb-cc10dddd-L1-202007012027-04.std
aaaaaa-bbbb-cc10dddd-L1-202007012027-05.std
aaaaaa-bbbb-cc10dddd-L1-202007012027-06.std
aaaaaa-bbbb-cc10dddd-L1-202007012027-07.std
aaaaaa-bbbb-cc10dddd-L1-202007012027-08.std
aaaaaa-bbbb-cc10dddd-L1-202007012027-09.std
aaaaaa-bbbb-cc10dddd-L1-202007012027-10.std
aaaaaa-bbbb-cc10dddd-L1-202007012027.ref
aaaaaa-bbbb-cc10dddd-L1-202007012039-00.std
aaaaaa-bbbb-cc10dddd-L1-202007012039-01.std
aaaaaa-bbbb-cc10dddd-L1-202007012039-02.std
aaaaaa-bbbb-cc10dddd-L1-202007012039-03.std
aaaaaa-bbbb-cc10dddd-L1-202007012039-04.std
aaaaaa-bbbb-cc10dddd-L1-202007012039-05.std
aaaaaa-bbbb-cc10dddd-L1-202007012039-06.std
aaaaaa-bbbb-cc10dddd-L1-202007012039-07.std
aaaaaa-bbbb-cc10dddd-L1-202007012039-08.std
aaaaaa-bbbb-cc10dddd-L1-202007012039-09.std
aaaaaa-bbbb-cc10dddd-L1-202007012039-10.std
aaaaaa-bbbb-cc10dddd-L1-202007012039.ref
aaaaaa-bbbb-cc10dddd-L1-202007012050-00.std
aaaaaa-bbbb-cc10dddd-L1-202007012050-01.std
aaaaaa-bbbb-cc10dddd-L1-202007012050-02.std
aaaaaa-bbbb-cc10dddd-L1-202007012050-03.std
aaaaaa-bbbb-cc10dddd-L1-202007012050-04.std
aaaaaa-bbbb-cc10dddd-L1-202007012050-05.std
aaaaaa-bbbb-cc10dddd-L1-202007012050-06.std
aaaaaa-bbbb-cc10dddd-L1-202007012050-07.std
aaaaaa-bbbb-cc10dddd-L1-202007012050-08.std
aaaaaa-bbbb-cc10dddd-L1-202007012050-09.std
aaaaaa-bbbb-cc10dddd-L1-202007012050-10.std
aaaaaa-bbbb-cc10dddd-L1-202007012050.ref
aaaaaa-bbbb-cc10dddd-L1-202007012102-00.std
aaaaaa-bbbb-cc10dddd-L1-202007012102-01.std
aaaaaa-bbbb-cc10dddd-L1-202007012102-02.std
aaaaaa-bbbb-cc10dddd-L1-202007012102-03.std
aaaaaa-bbbb-cc10dddd-L1-202007012102-04.std
aaaaaa-bbbb-cc10dddd-L1-202007012102-05.std
aaaaaa-bbbb-cc10dddd-L1-202007012102-06.std
aaaaaa-bbbb-cc10dddd-L1-202007012102-07.std
aaaaaa-bbbb-cc10dddd-L1-202007012102-08.std
aaaaaa-bbbb-cc10dddd-L1-202007012102-09.std
aaaaaa-bbbb-cc10dddd-L1-202007012102-10.std
aaaaaa-bbbb-cc10dddd-L1-202007012102.ref
aaaaaa-bbbb-cc10dddd-L1-202007012113-00.std
aaaaaa-bbbb-cc10dddd-L1-202007012113-01.std
aaaaaa-bbbb-cc10dddd-L1-202007012113-02.std
aaaaaa-bbbb-cc10dddd-L1-202007012113-03.std
aaaaaa-bbbb-cc10dddd-L1-202007012113-04.std
aaaaaa-bbbb-cc10dddd-L1-202007012113-05.std
aaaaaa-bbbb-cc10dddd-L1-202007012113-06.std
aaaaaa-bbbb-cc10dddd-L1-202007012113-07.std
aaaaaa-bbbb-cc10dddd-L1-202007012113-08.std
aaaaaa-bbbb-cc10dddd-L1-202007012113-09.std
aaaaaa-bbbb-cc10dddd-L1-202007012113-10.std
aaaaaa-bbbb-cc10dddd-L1-202007012113.ref
aaaaaa-bbbb-cc10dddd-L1-202007012125-00.std
aaaaaa-bbbb-cc10dddd-L1-202007012125-01.std
aaaaaa-bbbb-cc10dddd-L1-202007012125-02.std
aaaaaa-bbbb-cc10dddd-L1-202007012125-03.std
aaaaaa-bbbb-cc10dddd-L1-202007012125-04.std
aaaaaa-bbbb-cc10dddd-L1-202007012125-05.std
aaaaaa-bbbb-cc10dddd-L1-202007012125-06.std
aaaaaa-bbbb-cc10dddd-L1-202007012125-07.std
aaaaaa-bbbb-cc10dddd-L1-202007012125-08.std
aaaaaa-bbbb-cc10dddd-L1-202007012125-09.std
aaaaaa-bbbb-cc10dddd-L1-202007012125-10.std
aaaaaa-bbbb-cc10dddd-L1-202007012125.ref
aaaaaa-bbbb-cc10dddd-L1-202007012136-00.std
aaaaaa-bbbb-cc10dddd-L1-202007012136-01.std
aaaaaa-bbbb-cc10dddd-L1-202007012136-02.std
aaaaaa-bbbb-cc10dddd-L1-202007012136-03.std
aaaaaa-bbbb-cc10dddd-L1-202007012136-04.std
aaaaaa-bbbb-cc10dddd-L1-202007012136-05.std
aaaaaa-bbbb-cc10dddd-L1-202007012136-06.std
aaaaaa-bbbb-cc10dddd-L1-202007012136-07.std
aaaaaa-bbbb-cc10dddd-L1-202007012136-08.std
aaaaaa-bbbb-cc10dddd-L1-202007012136-09.std
aaaaaa-bbbb-cc10dddd-L1-202007012136-10.std
aaaaaa-bbbb-cc10dddd-L1-202007012136.ref
aaaaaa-bbbb-cc10dddd-L1-202007012148-00.std
aaaaaa-bbbb-cc10dddd-L1-202007012148-01.std
aaaaaa-bbbb-cc10dddd-L1-202007012148-02.std
aaaaaa-bbbb-cc10dddd-L1-202007012148-03.std
aaaaaa-bbbb-cc10dddd-L1-202007012148-04.std
aaaaaa-bbbb-cc10dddd-L1-202007012148-05.std
aaaaaa-bbbb-cc10dddd-L1-202007012148-06.std
aaaaaa-bbbb-cc10dddd-L1-202007012148-07.std
aaaaaa-bbbb-cc10dddd-L1-202007012148-08.std
aaaaaa-bbbb-cc10dddd-L1-202007012148-09.std
aaaaaa-bbbb-cc10dddd-L1-202007012148-10.std
aaaaaa-bbbb-cc10dddd-L1-202007012148.ref
aaaaaa-bbbb-cc10dddd-L1-202007012159-00.std
aaaaaa-bbbb-cc10dddd-L1-202007012159-01.std
aaaaaa-bbbb-cc10dddd-L1-202007012159-02.std
aaaaaa-bbbb-cc10dddd-L1-202007012159-03.std
aaaaaa-bbbb-cc10dddd-L1-202007012159-04.std
aaaaaa-bbbb-cc10dddd-L1-202007012159-05.std
aaaaaa-bbbb-cc10dddd-L1-202007012159-06.std
aaaaaa-bbbb-cc10dddd-L1-202007012159-07.std
aaaaaa-bbbb-cc10dddd-L1-202007012159-08.std
aaaaaa-bbbb-cc10dddd-L1-202007012159-09.std
aaaaaa-bbbb-cc10dddd-L1-202007012159-10.std
aaaaaa-bbbb-cc10dddd-L1-202007012159.ref
aaaaaa-bbbb-cc10-dddd-L1-202007012211-00.std
aaaaaa-bbbb-cc10-dddd-L1-202007012211-01.std
aaaaaa-bbbb-cc10-dddd-L1-202007012211-02.std
aaaaaa-bbbb-cc10-dddd-L1-202007012211-03.std
aaaaaa-bbbb-cc10-dddd-L1-202007012211-04.std
aaaaaa-bbbb-cc10-dddd-L1-202007012211-05.std
aaaaaa-bbbb-cc10-dddd-L1-202007012211-06.std
aaaaaa-bbbb-cc10-dddd-L1-202007012211-07.std
aaaaaa-bbbb-cc10-dddd-L1-202007012211-08.std
aaaaaa-bbbb-cc10-dddd-L1-202007012211-09.std
aaaaaa-bbbb-cc10-dddd-L1-202007012211-10.std
aaaaaa-bbbb-cc10-dddd-L1-202007012211.ref
aaaaaa-bbbb-cc10-dddd-L1-202007012222-00.std
aaaaaa-bbbb-cc10-dddd-L1-202007012222-01.std
aaaaaa-bbbb-cc10-dddd-L1-202007012222-02.std
aaaaaa-bbbb-cc10-dddd-L1-202007012222-03.std
aaaaaa-bbbb-cc10-dddd-L1-202007012222-04.std
aaaaaa-bbbb-cc10-dddd-L1-202007012222-05.std
aaaaaa-bbbb-cc10-dddd-L1-202007012222-06.std
aaaaaa-bbbb-cc10-dddd-L1-202007012222-07.std
aaaaaa-bbbb-cc10-dddd-L1-202007012222-08.std
aaaaaa-bbbb-cc10-dddd-L1-202007012222-09.std
aaaaaa-bbbb-cc10-dddd-L1-202007012222-10.std
aaaaaa-bbbb-cc10-dddd-L1-202007012222.ref
aaaaaa-bbbb-cc10-dddd-L1-202007012234-00.std
aaaaaa-bbbb-cc10-dddd-L1-202007012234-01.std
aaaaaa-bbbb-cc10-dddd-L1-202007012234-02.std
aaaaaa-bbbb-cc10-dddd-L1-202007012234-03.std
aaaaaa-bbbb-cc10-dddd-L1-202007012234-04.std
aaaaaa-bbbb-cc10-dddd-L1-202007012234-05.std
aaaaaa-bbbb-cc10-dddd-L1-202007012234-06.std
aaaaaa-bbbb-cc10-dddd-L1-202007012234-07.std
aaaaaa-bbbb-cc10-dddd-L1-202007012234-08.std
aaaaaa-bbbb-cc10-dddd-L1-202007012234-09.std
aaaaaa-bbbb-cc10-dddd-L1-202007012234-10.std
aaaaaa-bbbb-cc10-dddd-L1-202007012234.ref
aaaaaa-bbbb-cc10-dddd-L1-202007012245-00.std
aaaaaa-bbbb-cc10-dddd-L1-202007012245-01.std
aaaaaa-bbbb-cc10-dddd-L1-202007012245-02.std
aaaaaa-bbbb-cc10-dddd-L1-202007012245-03.std
aaaaaa-bbbb-cc10-dddd-L1-202007012245-04.std
aaaaaa-bbbb-cc10-dddd-L1-202007012245-05.std
aaaaaa-bbbb-cc10-dddd-L1-202007012245-06.std
aaaaaa-bbbb-cc10-dddd-L1-202007012245-07.std
aaaaaa-bbbb-cc10-dddd-L1-202007012245-08.std
aaaaaa-bbbb-cc10-dddd-L1-202007012245-09.std
aaaaaa-bbbb-cc10-dddd-L1-202007012245-10.std
aaaaaa-bbbb-cc10-dddd-L1-202007012245.ref
aaaaaa-bbbb-cc10-dddd-L1-202007012257-00.std
aaaaaa-bbbb-cc10-dddd-L1-202007012257-01.std
aaaaaa-bbbb-cc10-dddd-L1-202007012257-02.std
aaaaaa-bbbb-cc10-dddd-L1-202007012257-03.std
aaaaaa-bbbb-cc10-dddd-L1-202007012257-04.std
aaaaaa-bbbb-cc10-dddd-L1-202007012257-05.std
aaaaaa-bbbb-cc10-dddd-L1-202007012257-06.std
aaaaaa-bbbb-cc10-dddd-L1-202007012257-07.std
aaaaaa-bbbb-cc10-dddd-L1-202007012257-08.std
aaaaaa-bbbb-cc10-dddd-L1-202007012257-09.std
aaaaaa-bbbb-cc10-dddd-L1-202007012257-10.std
aaaaaa-bbbb-cc10-dddd-L1-202007012257.ref
aaaaaa-bbbb-cc10-dddd-L1-202007012308-00.std
aaaaaa-bbbb-cc10-dddd-L1-202007012308-01.std
aaaaaa-bbbb-cc10-dddd-L1-202007012308-02.std
aaaaaa-bbbb-cc10-dddd-L1-202007012308-03.std
aaaaaa-bbbb-cc10-dddd-L1-202007012308-04.std
aaaaaa-bbbb-cc10-dddd-L1-202007012308-05.std
aaaaaa-bbbb-cc10-dddd-L1-202007012308-06.std
aaaaaa-bbbb-cc10-dddd-L1-202007012308-07.std
aaaaaa-bbbb-cc10-dddd-L1-202007012308-08.std
aaaaaa-bbbb-cc10-dddd-L1-202007012308-09.std
aaaaaa-bbbb-cc10-dddd-L1-202007012308-10.std
aaaaaa-bbbb-cc10-dddd-L1-202007012308.ref
aaaaaa-bbbb-cc10-dddd-L1-202007012319-00.std
aaaaaa-bbbb-cc10-dddd-L1-202007012319-01.std
aaaaaa-bbbb-cc10-dddd-L1-202007012319-02.std
aaaaaa-bbbb-cc10-dddd-L1-202007012319-03.std
aaaaaa-bbbb-cc10-dddd-L1-202007012319-04.std
aaaaaa-bbbb-cc10-dddd-L1-202007012319-05.std
aaaaaa-bbbb-cc10-dddd-L1-202007012319-06.std
aaaaaa-bbbb-cc10-dddd-L1-202007012319-07.std
aaaaaa-bbbb-cc10-dddd-L1-202007012319-08.std
aaaaaa-bbbb-cc10-dddd-L1-202007012319-09.std
aaaaaa-bbbb-cc10-dddd-L1-202007012319-10.std
aaaaaa-bbbb-cc10-dddd-L1-202007012319.ref
aaaaaa-bbbb-cc10-dddd-L1-202007012331-00.std
aaaaaa-bbbb-cc10-dddd-L1-202007012331-01.std
aaaaaa-bbbb-cc10-dddd-L1-202007012331-02.std
aaaaaa-bbbb-cc10-dddd-L1-202007012331-03.std
aaaaaa-bbbb-cc10-dddd-L1-202007012331-04.std
aaaaaa-bbbb-cc10-dddd-L1-202007012331-05.std
aaaaaa-bbbb-cc10-dddd-L1-202007012331-06.std
aaaaaa-bbbb-cc10-dddd-L1-202007012331-07.std
aaaaaa-bbbb-cc10-dddd-L1-202007012331-08.std
aaaaaa-bbbb-cc10-dddd-L1-202007012331-09.std
aaaaaa-bbbb-cc10-dddd-L1-202007012331-10.std
aaaaaa-bbbb-cc10-dddd-L1-202007012331.ref
aaaaaa-bbbb-cc10-dddd-L1-202007012342-00.std
aaaaaa-bbbb-cc10-dddd-L1-202007012342-01.std
aaaaaa-bbbb-cc10-dddd-L1-202007012342-02.std
aaaaaa-bbbb-cc10-dddd-L1-202007012342-03.std
aaaaaa-bbbb-cc10-dddd-L1-202007012342-04.std
aaaaaa-bbbb-cc10-dddd-L1-202007012342-05.std
aaaaaa-bbbb-cc10-dddd-L1-202007012342-06.std
aaaaaa-bbbb-cc10-dddd-L1-202007012342-07.std
aaaaaa-bbbb-cc10-dddd-L1-202007012342-08.std
aaaaaa-bbbb-cc10-dddd-L1-202007012342-09.std
aaaaaa-bbbb-cc10-dddd-L1-202007012342-10.std
aaaaaa-bbbb-cc10-dddd-L1-202007012342.ref
aaaaaa-bbbb-cc10-dddd-L1-202007012354-00.std
aaaaaa-bbbb-cc10-dddd-L1-202007012354-01.std
aaaaaa-bbbb-cc10-dddd-L1-202007012354-02.std
aaaaaa-bbbb-cc10-dddd-L1-202007012354-03.std
aaaaaa-bbbb-cc10-dddd-L1-202007012354-04.std
aaaaaa-bbbb-cc10-dddd-L1-202007012354-05.std
aaaaaa-bbbb-cc10-dddd-L1-202007012354-06.std
aaaaaa-bbbb-cc10-dddd-L1-202007012354-07.std
aaaaaa-bbbb-cc10-dddd-L1-202007012354-08.std
aaaaaa-bbbb-cc10-dddd-L1-202007012354-09.std
aaaaaa-bbbb-cc10-dddd-L1-202007012354-10.std
aaaaaa-bbbb-cc10-dddd-L1-202007012354.ref
aaaaaa-bbbb-cc10-dddd-L1-202007020005-00.std
aaaaaa-bbbb-cc10-dddd-L1-202007020005-01.std
aaaaaa-bbbb-cc10-dddd-L1-202007020005-02.std
aaaaaa-bbbb-cc10-dddd-L1-202007020005-03.std
aaaaaa-bbbb-cc10-dddd-L1-202007020005-04.std
aaaaaa-bbbb-cc10-dddd-L1-202007020005-05.std
aaaaaa-bbbb-cc10-dddd-L1-202007020005-06.std
aaaaaa-bbbb-cc10-dddd-L1-202007020005-07.std
aaaaaa-bbbb-cc10-dddd-L1-202007020005-08.std
aaaaaa-bbbb-cc10-dddd-L1-202007020005-09.std
aaaaaa-bbbb-cc10-dddd-L1-202007020005-10.std
aaaaaa-bbbb-cc10-dddd-L1-202007020005.ref
aaaaaa-bbbb-cc10-dddd-L1-202007020017-00.std
aaaaaa-bbbb-cc10-dddd-L1-202007020017-01.std
aaaaaa-bbbb-cc10-dddd-L1-202007020017-02.std
aaaaaa-bbbb-cc10-dddd-L1-202007020017-03.std
aaaaaa-bbbb-cc10-dddd-L1-202007020017-04.std
aaaaaa-bbbb-cc10-dddd-L1-202007020017-05.std
aaaaaa-bbbb-cc10-dddd-L1-202007020017-06.std
aaaaaa-bbbb-cc10-dddd-L1-202007020017-07.std
aaaaaa-bbbb-cc10-dddd-L1-202007020017-08.std
aaaaaa-bbbb-cc10-dddd-L1-202007020017-09.std
aaaaaa-bbbb-cc10-dddd-L1-202007020017-10.std
aaaaaa-bbbb-cc10-dddd-L1-202007020017.ref
aaaaaa-bbbb-cc10-dddd-L1-202007020028-00.std
aaaaaa-bbbb-cc10-dddd-L1-202007020028-01.std
aaaaaa-bbbb-cc10-dddd-L1-202007020028-02.std
aaaaaa-bbbb-cc10-dddd-L1-202007020028-03.std
aaaaaa-bbbb-cc10-dddd-L1-202007020028-04.std
aaaaaa-bbbb-cc10-dddd-L1-202007020028-05.std
aaaaaa-bbbb-cc10-dddd-L1-202007020028-06.std
aaaaaa-bbbb-cc10-dddd-L1-202007020028-07.std
aaaaaa-bbbb-cc10-dddd-L1-202007020028-08.std
aaaaaa-bbbb-cc10-dddd-L1-202007020028-09.std
aaaaaa-bbbb-cc10-dddd-L1-202007020028-10.std
aaaaaa-bbbb-cc10-dddd-L1-202007020028.ref
aaaaaa-bbbb-cc10-dddd-L1-202007020040-00.std
aaaaaa-bbbb-cc10-dddd-L1-202007020040-01.std
aaaaaa-bbbb-cc10-dddd-L1-202007020040-02.std
aaaaaa-bbbb-cc10-dddd-L1-202007020040-03.std
aaaaaa-bbbb-cc10-dddd-L1-202007020040-04.std
aaaaaa-bbbb-cc10-dddd-L1-202007020040-05.std
aaaaaa-bbbb-cc10-dddd-L1-202007020040-06.std
aaaaaa-bbbb-cc10-dddd-L1-202007020040-07.std
aaaaaa-bbbb-cc10-dddd-L1-202007020040-08.std
aaaaaa-bbbb-cc10-dddd-L1-202007020040-09.std
aaaaaa-bbbb-cc10-dddd-L1-202007020040-10.std
aaaaaa-bbbb-cc10-dddd-L1-202007020040.ref
aaaaaa-bbbb-cc10-dddd-L1-202007020051-00.std
aaaaaa-bbbb-cc10-dddd-L1-202007020051-01.std
aaaaaa-bbbb-cc10-dddd-L1-202007020051-02.std
aaaaaa-bbbb-cc10-dddd-L1-202007020051-03.std
aaaaaa-bbbb-cc10-dddd-L1-202007020051-04.std
aaaaaa-bbbb-cc10-dddd-L1-202007020051-05.std
aaaaaa-bbbb-cc10-dddd-L1-202007020051-06.std
aaaaaa-bbbb-cc10-dddd-L1-202007020051-07.std
aaaaaa-bbbb-cc10-dddd-L1-202007020051-08.std
aaaaaa-bbbb-cc10-dddd-L1-202007020051-09.std
aaaaaa-bbbb-cc10-dddd-L1-202007020051-10.std
aaaaaa-bbbb-cc10-dddd-L1-202007020051.ref
aaaaaa-bbbb-cc10-dddd-L1-202007020103-00.std
aaaaaa-bbbb-cc10-dddd-L1-202007020103-01.std
aaaaaa-bbbb-cc10-dddd-L1-202007020103-02.std
aaaaaa-bbbb-cc10-dddd-L1-202007020103-03.std
aaaaaa-bbbb-cc10-dddd-L1-202007020103-04.std
aaaaaa-bbbb-cc10-dddd-L1-202007020103-05.std
aaaaaa-bbbb-cc10-dddd-L1-202007020103-06.std
aaaaaa-bbbb-cc10-dddd-L1-202007020103-07.std
aaaaaa-bbbb-cc10-dddd-L1-202007020103-08.std
aaaaaa-bbbb-cc10-dddd-L1-202007020103-09.std
aaaaaa-bbbb-cc10-dddd-L1-202007020103-10.std
aaaaaa-bbbb-cc10-dddd-L1-202007020103.ref
aaaaaa-bbbb-cc10-dddd-L1-202007020114-00.std
aaaaaa-bbbb-cc10-dddd-L1-202007020114-01.std
aaaaaa-bbbb-cc10-dddd-L1-202007020114-02.std
aaaaaa-bbbb-cc10-dddd-L1-202007020114-03.std
aaaaaa-bbbb-cc10-dddd-L1-202007020114-04.std
aaaaaa-bbbb-cc10-dddd-L1-202007020114-05.std
aaaaaa-bbbb-cc10-dddd-L1-202007020114-06.std
aaaaaa-bbbb-cc10-dddd-L1-202007020114-07.std
aaaaaa-bbbb-cc10-dddd-L1-202007020114-08.std
aaaaaa-bbbb-cc10-dddd-L1-202007020114-09.std
aaaaaa-bbbb-cc10-dddd-L1-202007020114-10.std
aaaaaa-bbbb-cc10-dddd-L1-202007020114.ref
aaaaaa-bbbb-cc10-dddd-L1-202007020125-00.std
aaaaaa-bbbb-cc10-dddd-L1-202007020125-01.std
aaaaaa-bbbb-cc10-dddd-L1-202007020125-02.std
aaaaaa-bbbb-cc10-dddd-L1-202007020125-03.std
aaaaaa-bbbb-cc10-dddd-L1-202007020125-04.std
aaaaaa-bbbb-cc10-dddd-L1-202007020125-05.std
aaaaaa-bbbb-cc10-dddd-L1-202007020125-06.std
aaaaaa-bbbb-cc10-dddd-L1-202007020125-07.std
aaaaaa-bbbb-cc10-dddd-L1-202007020125-08.std
aaaaaa-bbbb-cc10-dddd-L1-202007020125-09.std
aaaaaa-bbbb-cc10-dddd-L1-202007020125-10.std
aaaaaa-bbbb-cc10-dddd-L1-202007020125.ref
aaaaaa-bbbb-cc10-dddd-L1-202007020137-00.std
aaaaaa-bbbb-cc10-dddd-L1-202007020137-01.std
aaaaaa-bbbb-cc10-dddd-L1-202007020137-02.std
aaaaaa-bbbb-cc10-dddd-L1-202007020137-03.std
aaaaaa-bbbb-cc10-dddd-L1-202007020137-04.std
aaaaaa-bbbb-cc10-dddd-L1-202007020137-05.std
aaaaaa-bbbb-cc10-dddd-L1-202007020137-06.std
aaaaaa-bbbb-cc10-dddd-L1-202007020137-07.std
aaaaaa-bbbb-cc10-dddd-L1-202007020137-08.std
aaaaaa-bbbb-cc10-dddd-L1-202007020137-09.std
aaaaaa-bbbb-cc10-dddd-L1-202007020137-10.std
aaaaaa-bbbb-cc10-dddd-L1-202007020137.ref
aaaaaa-bbbb-cc10-dddd-L1-202007020148-00.std
aaaaaa-bbbb-cc10-dddd-L1-202007020148-01.std
aaaaaa-bbbb-cc10-dddd-L1-202007020148-02.std
aaaaaa-bbbb-cc10-dddd-L1-202007020148-03.std
aaaaaa-bbbb-cc10-dddd-L1-202007020148-04.std
aaaaaa-bbbb-cc10-dddd-L1-202007020148-05.std
aaaaaa-bbbb-cc10-dddd-L1-202007020148-06.std
aaaaaa-bbbb-cc10-dddd-L1-202007020148-07.std
aaaaaa-bbbb-cc10-dddd-L1-202007020148-08.std
aaaaaa-bbbb-cc10-dddd-L1-202007020148-09.std
aaaaaa-bbbb-cc10-dddd-L1-202007020148-10.std
aaaaaa-bbbb-cc10-dddd-L1-202007020148.ref
aaaaaa-bbbb-cc10-dddd-L1-202007020200-00.std
aaaaaa-bbbb-cc10-dddd-L1-202007020200-01.std
aaaaaa-bbbb-cc10-dddd-L1-202007020200-02.std
aaaaaa-bbbb-cc10-dddd-L1-202007020200-03.std
aaaaaa-bbbb-cc10-dddd-L1-202007020200-04.std
aaaaaa-bbbb-cc10-dddd-L1-202007020200-05.std
aaaaaa-bbbb-cc10-dddd-L1-202007020200-06.std
aaaaaa-bbbb-cc10-dddd-L1-202007020200-07.std
aaaaaa-bbbb-cc10-dddd-L1-202007020200-08.std
aaaaaa-bbbb-cc10-dddd-L1-202007020200-09.std
aaaaaa-bbbb-cc10-dddd-L1-202007020200-10.std
aaaaaa-bbbb-cc10-dddd-L1-202007020200.ref
aaaaaa-bbbb-cc10-dddd-L1-202007020211-00.std
aaaaaa-bbbb-cc10-dddd-L1-202007020211-01.std
aaaaaa-bbbb-cc10-dddd-L1-202007020211-02.std
aaaaaa-bbbb-cc10-dddd-L1-202007020211-03.std
aaaaaa-bbbb-cc10-dddd-L1-202007020211-04.std
aaaaaa-bbbb-cc10-dddd-L1-202007020211-05.std
aaaaaa-bbbb-cc10-dddd-L1-202007020211-06.std
aaaaaa-bbbb-cc10-dddd-L1-202007020211-07.std
aaaaaa-bbbb-cc10-dddd-L1-202007020211-08.std
aaaaaa-bbbb-cc10-dddd-L1-202007020211-09.std
aaaaaa-bbbb-cc10-dddd-L1-202007020211-10.std
aaaaaa-bbbb-cc10-dddd-L1-202007020211.ref
aaaaaa-bbbb-cc10-dddd-L1-202007020223-00.std
aaaaaa-bbbb-cc10-dddd-L1-202007020223-01.std
aaaaaa-bbbb-cc10-dddd-L1-202007020223-02.std
aaaaaa-bbbb-cc10-dddd-L1-202007020223-03.std
aaaaaa-bbbb-cc10-dddd-L1-202007020223-04.std
aaaaaa-bbbb-cc10-dddd-L1-202007020223-05.std
aaaaaa-bbbb-cc10-dddd-L1-202007020223-06.std
aaaaaa-bbbb-cc10-dddd-L1-202007020223-07.std
aaaaaa-bbbb-cc10-dddd-L1-202007020223-08.std
aaaaaa-bbbb-cc10-dddd-L1-202007020223-09.std
aaaaaa-bbbb-cc10-dddd-L1-202007020223-10.std
aaaaaa-bbbb-cc10-dddd-L1-202007020223.ref
aaaaaa-bbbb-cc10-dddd-L1-202007020234-00.std
aaaaaa-bbbb-cc10-dddd-L1-202007020234-01.std
aaaaaa-bbbb-cc10-dddd-L1-202007020234-02.std
aaaaaa-bbbb-cc10-dddd-L1-202007020234-03.std
aaaaaa-bbbb-cc10-dddd-L1-202007020234-04.std
aaaaaa-bbbb-cc10-dddd-L1-202007020234-05.std
aaaaaa-bbbb-cc10-dddd-L1-202007020234-06.std
aaaaaa-bbbb-cc10-dddd-L1-202007020234-07.std
aaaaaa-bbbb-cc10-dddd-L1-202007020234-08.std
aaaaaa-bbbb-cc10-dddd-L1-202007020234-09.std
aaaaaa-bbbb-cc10-dddd-L1-202007020234-10.std
aaaaaa-bbbb-cc10-dddd-L1-202007020234.ref
aaaaaa-bbbb-cc10-dddd-L1-202007020246-00.std
aaaaaa-bbbb-cc10-dddd-L1-202007020246-01.std
aaaaaa-bbbb-cc10-dddd-L1-202007020246-02.std
aaaaaa-bbbb-cc10-dddd-L1-202007020246-03.std
aaaaaa-bbbb-cc10-dddd-L1-202007020246-04.std
aaaaaa-bbbb-cc10-dddd-L1-202007020246-05.std
aaaaaa-bbbb-cc10-dddd-L1-202007020246-06.std
aaaaaa-bbbb-cc10-dddd-L1-202007020246-07.std
aaaaaa-bbbb-cc10-dddd-L1-202007020246-08.std
aaaaaa-bbbb-cc10-dddd-L1-202007020246-09.std
aaaaaa-bbbb-cc10-dddd-L1-202007020246-10.std
aaaaaa-bbbb-cc10-dddd-L1-202007020246.ref
aaaaaa-bbbb-cc10-dddd-L1-202007020257-00.std
aaaaaa-bbbb-cc10-dddd-L1-202007020257-01.std
aaaaaa-bbbb-cc10-dddd-L1-202007020257-02.std
aaaaaa-bbbb-cc10-dddd-L1-202007020257-03.std
aaaaaa-bbbb-cc10-dddd-L1-202007020257-04.std
aaaaaa-bbbb-cc10-dddd-L1-202007020257-05.std
aaaaaa-bbbb-cc10-dddd-L1-202007020257-06.std
aaaaaa-bbbb-cc10-dddd-L1-202007020257-07.std
aaaaaa-bbbb-cc10-dddd-L1-202007020257-08.std
aaaaaa-bbbb-cc10-dddd-L1-202007020257-09.std
aaaaaa-bbbb-cc10-dddd-L1-202007020257-10.std
aaaaaa-bbbb-cc10-dddd-L1-202007020257.ref

我使用的腳本。尋找更易讀的東西。瘋狂,但這個腳本確實有效。第一部分是設置主目錄。

# if the input directory has a trailing slash, remove it

if [ ! -z "$1" ]; then
 # remove trailing slash
 basedir=`echo "$1" | sed -e "s/\/$//"`
else
 # copy dirname
 basedir=$1
fi

if [ ! -d $basedir ]; then
 echo "Fatal error, argument is not a local directory -- bailing"
 exit 1
fi


#!/bin/sh
#

mkdir $sortdir/sort

for i in {11..23}; do
 mkdir $hrdir/01"$i"
done

for i in {00..08}; do
 mkdir $hrdir/02"$i"
done

for i in {01..10}; do
 mkdir $elevdir1/0111-"$i"
done

for i in {01..10}; do
 mkdir $elevdir2/0112-"$i"
done

for i in {01..10}; do
 mkdir $elevdir3/0113-"$i"
done

for i in {01..10}; do
 mkdir $elevdir4/0114-"$i"
done

for i in {01..10}; do
 mkdir $elevdir5/0115-"$i"
done

for i in {01..10}; do
 mkdir $elevdir6/0116-"$i"
done

for i in {01..10}; do
 mkdir $elevdir7/0117-"$i"
done

for i in {01..10}; do
 mkdir $elevdir8/0118-"$i"
done

for i in {01..10}; do
 mkdir $elevdir9/0119-"$i"
done

for i in {01..10}; do
 mkdir $elevdir10/0120-"$i"
done

for i in {01..10}; do
 mkdir $elevdir11/0121-"$i"
done

for i in {01..10}; do
 mkdir $elevdir12/0122-"$i"
done

for i in {01..10}; do
 mkdir $elevdir13/0123-"$i"
done

for i in {01..10}; do
 mkdir $elevdir14/0200-"$i"
done

for i in {01..10}; do
 mkdir $elevdir15/0201-"$i"
done

for i in {01..10}; do
 mkdir $elevdir16/0202-"$i"
done

for i in {01..10}; do
 mkdir $elevdir17/0203-"$i"
done

for i in {01..10}; do
 mkdir $elevdir18/0204-"$i"
done

for i in {01..10}; do
 mkdir $elevdir19/0205-"$i"
done

for i in {01..10}; do
 mkdir $elevdir20/0206-"$i"
done

for i in {01..10}; do
 mkdir $elevdir21/0207-"$i"
done

for i in {01..10}; do
 mkdir $elevdir22/0208-"$i"
done


for i in {11..23}; do
 mkdir $hrdir/01"$i"/01"$i"-ref
done

for i in {00..08}; do
 mkdir $hrdir/02"$i"/02"$i"-ref
done


for i in {01..10}; do 
 cp $stddir/aaaaaa-bbbb-cc10-dddd-L1-2020070111*-"$i".std $elevdir1/0111-"$i"
done


for i in {01..10}; do 
 cp $stddir/aaaaaa-bbbb-cc10-dddd-L1-2020070112*-"$i".std $elevdir2/0112-"$i"
done

for i in {01..10}; do 
 cp $stddir/aaaaaa-bbbb-cc10-dddd-L1-2020070113*-"$i".std $elevdir3/0113-"$i"
done


for i in {01..10}; do 
 cp $stddir/aaaaaa-bbbb-cc10-dddd-L1-2020070114*-"$i".std $elevdir4/0114-"$i"
done

for i in {01..10}; do 
 cp $stddir/aaaaaa-bbbb-cc10-dddd-L1-2020070115*-"$i".std $elevdir5/0115-"$i"
done

for i in {01..10}; do 
 cp $stddir/aaaaaa-bbbb-cc10-dddd-L1-2020070116*-"$i".std $elevdir6/0116-"$i"
done

for i in {01..10}; do 
 cp $stddir/aaaaaa-bbbb-cc10-dddd-L1-2020070117*-"$i".std $elevdir7/0117-"$i"
done


for i in {01..10}; do 
 cp $stddir/aaaaaa-bbbb-cc10-dddd-L1-2020070118*-"$i".std $elevdir8/0118-"$i"
done

for i in {01..10}; do 
 cp $stddir/aaaaaa-bbbb-cc10-dddd-L1-2020070119*-"$i".std $elevdir9/0119-"$i"
done

for i in {01..10}; do 
 cp $stddir/aaaaaa-bbbb-cc10-dddd-L1-2020070120*-"$i".std $elevdir10/0120-"$i"
done

for i in {01..10}; do 
 cp $stddir/aaaaaa-bbbb-cc10-dddd-L1-2020070121*-"$i".std $elevdir11/0121-"$i"
done

for i in {01..10}; do 
 cp $stddir/aaaaaa-bbbb-cc10-dddd-L1-2020070122*-"$i".std $elevdir12/0122-"$i"
done

for i in {01..10}; do 
 cp $stddir/aaaaaa-bbbb-cc10-dddd-L1-2020070123*-"$i".std $elevdir13/0123-"$i"
done

for i in {01..10}; do 
 cp $stddir/aaaaaa-bbbb-cc10-dddd-L1-2020070200*-"$i".std $elevdir14/0200-"$i"
done

for i in {01..10}; do 
 cp $stddir/aaaaaa-bbbb-cc10-dddd-L1-2020070201*-"$i".std $elevdir15/0201-"$i"
done

for i in {01..10}; do 
 cp $stddir/aaaaaa-bbbb-cc10-dddd-L1-2020070202*-"$i".std $elevdir16/0202-"$i"
done

for i in {01..10}; do 
 cp $stddir/aaaaaa-bbbb-cc10-dddd-L1-2020070203*-"$i".std $elevdir17/0203-"$i"
done

for i in {01..10}; do 
 cp $stddir/aaaaaa-bbbb-cc10-dddd-L1-2020070204*-"$i".std $elevdir18/0204-"$i"
done

for i in {01..10}; do 
 cp $stddir/aaaaaa-bbbb-cc10-dddd-L1-2020070205*-"$i".std $elevdir19/0205-"$i"
done

for i in {01..10}; do 
 cp $stddir/aaaaaa-bbbb-cc10-dddd-L1-2020070206*-"$i".std $elevdir20/0206-"$i"
done

for i in {01..10}; do 
 cp $stddir/aaaaaa-bbbb-cc10-dddd-L1-2020070207*-"$i".std $elevdir21/0207-"$i"
done

for i in {01..10}; do 
 cp $stddir/aaaaaa-bbbb-cc10-dddd-L1-2020070208*-"$i".std $elevdir22/0208-"$i"
done

cp $stddir/aaaaaa-bbbb-cc10-dddd-L1-2020070111*.ref  $elevdir1/0111-ref
cp $stddir/aaaaaa-bbbb-cc10-dddd-L1-2020070112*.ref  $elevdir2/0112-ref
cp $stddir/aaaaaa-bbbb-cc10-dddd-L1-2020070113*.ref  $elevdir3/0113-ref
cp $stddir/aaaaaa-bbbb-cc10-dddd-L1-2020070114*.ref  $elevdir4/0114-ref
cp $stddir/aaaaaa-bbbb-cc10-dddd-L1-2020070115*.ref  $elevdir5/0115-ref
cp $stddir/aaaaaa-bbbb-cc10-dddd-L1-2020070116*.ref  $elevdir6/0116-ref
cp $stddir/aaaaaa-bbbb-cc10-dddd-L1-2020070117*.ref  $elevdir7/0117-ref
cp $stddir/aaaaaa-bbbb-cc10-dddd-L1-2020070118*.ref  $elevdir8/0118-ref
cp $stddir/aaaaaa-bbbb-cc10-dddd-L1-2020070119*.ref  $elevdir9/0119-ref
cp $stddir/aaaaaa-bbbb-cc10-dddd-L1-2020070120*.ref  $elevdir10/0120-ref
cp $stddir/aaaaaa-bbbb-cc10-dddd-L1-2020070121*.ref  $elevdir11/0121-ref
cp $stddir/aaaaaa-bbbb-cc10-dddd-L1-2020070122*.ref  $elevdir12/0122-ref
cp $stddir/aaaaaa-bbbb-cc10-dddd-L1-2020070123*.ref  $elevdir13/0123-ref
cp $stddir/aaaaaa-bbbb-cc10-dddd-L1-2020070200*.ref  $elevdir14/0200-ref
cp $stddir/aaaaaa-bbbb-cc10-dddd-L1-2020070201*.ref  $elevdir15/0201-ref
cp $stddir/aaaaaa-bbbb-cc10-dddd-L1-2020070202*.ref  $elevdir16/0202-ref
cp $stddir/aaaaaa-bbbb-cc10-dddd-L1-2020070203*.ref  $elevdir17/0203-ref
cp $stddir/aaaaaa-bbbb-cc10-dddd-L1-2020070204*.ref  $elevdir18/0204-ref
cp $stddir/aaaaaa-bbbb-cc10-dddd-L1-2020070205*.ref  $elevdir19/0205-ref
cp $stddir/aaaaaa-bbbb-cc10-dddd-L1-2020070206*.ref  $elevdir20/0206-ref
cp $stddir/aaaaaa-bbbb-cc10-dddd-L1-2020070207*.ref  $elevdir21/0207-ref
cp $stddir/aaaaaa-bbbb-cc10-dddd-L1-2020070208*.ref  $elevdir22/0208-ref

為了簡化這些目錄創建,您可以考慮將-p選項部署到mkdir,並擴展您對“大括號擴展”的使用,例如

for i in {1..22}
 do    echo mkdir -p ${elevdir}$i/0$(printf "%1d%02d" $((i/14+1)) $(((i+10)%24)))-{01..10}
 done
mkdir -p Josef1/0111-01 Josef1/0111-02 Josef1/0111-03 ...
mkdir -p Josef2/0112-01 Josef2/0112-02 Josef2/0112-03 ...
mkdir -p Josef3/0113-01 Josef3/0113-02 Josef3/0113-03 ...
mkdir -p Josef4/0114-01 Josef4/0114-02 Josef4/0114-03 ...
mkdir -p Josef5/0115-01 Josef5/0115-02 Josef5/0115-03 ...
mkdir -p Josef6/0116-01 Josef6/0116-02 Josef6/0116-03 ...
mkdir -p Josef7/0117-01 Josef7/0117-02 Josef7/0117-03 ...
mkdir -p Josef8/0118-01 Josef8/0118-02 Josef8/0118-03 ...
mkdir -p Josef9/0119-01 Josef9/0119-02 Josef9/0119-03 ...
mkdir -p Josef10/0120-01 Josef10/0120-02 Josef10/0120-03 ...

echo是一種預防措施;如果您看到的內容滿意,請刪除。

如果確信,請嘗試與實際複製操作類似的方法。至少你可以cp在一個單一的內收集所有for i in {1..10}

for i in {1..10}
 do cp ...
    cp ...
    cp ...
 done

***編輯:***或者,更簡單,嘗試

for i in {111..123} {200..208};   do    echo mkdir -p ${elevdir}$((i-110-i/200*76))/0$i-{01..10};   done

引用自:https://unix.stackexchange.com/questions/688424