teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

2

追記

2019/10/30 07:45

投稿

Y.H.
Y.H.

スコア7918

answer CHANGED
@@ -2,4 +2,31 @@
2
2
  ~~でkazumasamatsumoさんがベストアンサーに選ばれている回答では~~
3
3
  こちらの[回答](https://teratail.com/questions/220210#reply-322936)の方でした。
4
4
  `find`コマンドが使用されているので、`type`オプションを指定し、
5
- 対象をファイルのみにすればよいだけでは?
5
+ 対象をファイルのみにすればよいだけでは?
6
+
7
+
8
+ ```
9
+ $ tree
10
+ .
11
+ ├── test-0
12
+ ├── test-1
13
+ │   └── test-1-1
14
+ │   └── test-1-1-1.txt
15
+ └── test-2
16
+ └── test-2.txt
17
+
18
+ $ find . -depth -type f | grep test | sed -e 's#(.*)(/[^/]*)#mv \1\2 \1\2#' -e 's#(.*)test([^/])#\1honban\2#'
19
+ mv ./test-1/test-1-1/test-1-1-1.txt ./test-1/test-1-1/honban-1-1-1.txt
20
+ mv ./test-2/test-2.txt ./test-2/honban-2.txt
21
+
22
+ $ find . -depth -type f | grep test | sed -e 's#(.*)(/[^/]*)#mv \1\2 \1\2#' -e 's#(.*)test([^/])#\1honban\2#' | sh
23
+ $ tree
24
+ .
25
+ ├── test-0
26
+ ├── test-1
27
+ │   └── test-1-1
28
+ │   └── honban-1-1-1.txt
29
+ └── test-2
30
+ └── honban-2.txt
31
+
32
+ ```

1

回答修正

2019/10/30 07:45

投稿

Y.H.
Y.H.

スコア7918

answer CHANGED
@@ -1,4 +1,5 @@
1
1
  [(teratail.com)シェルコマンドでフォルダより以下の階層全ての名前を変更したい](https://teratail.com/questions/220210)
2
- でkazumasamatsumoさんがベストアンサーに選ばれている回答では
2
+ ~~でkazumasamatsumoさんがベストアンサーに選ばれている回答では~~
3
+ こちらの[回答](https://teratail.com/questions/220210#reply-322936)の方でした。
3
4
  `find`コマンドが使用されているので、`type`オプションを指定し、
4
5
  対象をファイルのみにすればよいだけでは?