ls * | sed -e 'p;s/foo/bar/' | xargs -n2 mv
sed [OPTION]
-e script, --expression=script
add the script to the commands to be executed
xargs [OPTION]
--max-args=max-args, -n max-args
Use at most max-args arguments per command line. Fewer than max-args arguments will be used if the size (see the -s option) is exceeded, unless
the -x option is given, in which case xargs will exit.
bulk rename files with sed, one-liner
Renames all files in a directory named foo to bar.
foobar1 gets renamed to barbar1
barfoo2 gets renamed to barbar2
fooobarfoo gets renamed to barobarfoo
[root@oracle test1]# ls
footest1 testfoo1
[root@oracle test1]# ls * | sed -e 'p;s/foo/bar/' | xargs -n2 mv
[root@oracle test1]# ls
bartest1 testbar1
[ref] http://www.commandlinefu.com/commands/view/8368/bulk-rename-files-with-sed-one-liner
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 30 |
아우겐나이스
|
21년 전 | 4041 | |
| 29 |
아우겐나이스
|
21년 전 | 4432 | |
| 28 |
아우겐나이스
|
21년 전 | 3455 | |
| 27 | 21년 전 | 5821 | ||
| 26 | 21년 전 | 3093 | ||
| 25 | 21년 전 | 6071 | ||
| 24 | 18년 전 | 3642 | ||
| 23 | 21년 전 | 3629 | ||
| 22 | 21년 전 | 4240 | ||
| 21 | 21년 전 | 3812 | ||
| 20 | 21년 전 | 4213 | ||
| 19 | 21년 전 | 6674 | ||
| 18 | 21년 전 | 4731 | ||
| 17 | 21년 전 | 6981 | ||
| 16 | 21년 전 | 4165 | ||
| 15 | 21년 전 | 2622 | ||
| 14 | 21년 전 | 4963 | ||
| 13 | 21년 전 | 3395 | ||
| 12 |
Recluse
|
21년 전 | 3869 | |
| 11 |
아우겐나이스
|
21년 전 | 3566 | |
| 10 |
Recluse
|
21년 전 | 3388 | |
| 9 | 21년 전 | 3976 | ||
| 8 | 21년 전 | 5156 | ||
| 7 | 21년 전 | 4753 | ||
| 6 | 21년 전 | 5672 | ||
| 5 | 21년 전 | 4108 | ||
| 4 | 21년 전 | 4827 | ||
| 3 | 21년 전 | 4735 | ||
| 2 | 21년 전 | 3232 | ||
| 1 | 22년 전 | 4336 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기