Advertisement
Advertisement

More Related Content

Advertisement
Advertisement

[5분 따라하기] bash에서 파일 확장자 변경

  1. [5분 따라하기] bash에서 파일 확장자 변경 박재호(jrogue@gmail.com)
  2. 참고 자료 • <컴퓨터 vs 책> 블로그 • http://jhrogue.blogspot.com/ • OKdevTV 유튜브 방송 • 오늘 방송: • https://www.youtube.com/watch?v=hmnBfM5PfH0&list=PLdntWJk2tJPLKNNYBV Cxnde2PEB6dzbSL&index=6 • 5분 따라하기 리스트: • https://www.youtube.com/playlist?list=PLdntWJk2tJPLKNNYBVCxnde2PEB6dzbSL • 슬라이드 셰어 • https://www.slideshare.net/jrogue/presentations • ASCIINEMA • https://asciinema.org/~jrogue
  3. 오늘 소개할 내용 • 배시(bash) 셸에서 파일 확장자를 손쉽게 변경할 수 있을까? • 일일이 파일 이름을 열거하지 않고 파일 확장자만 살짝 교체할 수 있다면?
  4. 몇 가지 힌트 • 파일 하나를 바꾸려면? 정규식 활용 • !#:1:s/txt/json → 현재 명령행에서 첫째 인수를 가져와 확장자 txt를 json 으로 대체 • 응용) 파일 이름에도 적용 가능 • 파일 여러 개를 바꾸려면? find 명령 활용 • -exec 활용 • 주의: {}
  5. 스크립트 $ touch conf.txt db.txt was.txt $ mv conf.txt !#:1:s/txt/json $ mv conf.json !#:1:s/conf/config $ mv config.json !#:1:s/json/txt $ find . -name '*.txt' -exec sh -c 'mv "$0" "${0%.txt}.json"' {} ; 명령행에서 직접 실행
  6. 보면서 따라해봅시다~~~ • https://asciinema.org/a/323790
Advertisement