이름이 250 개 이하인 파일이 있습니다.
no_responseEvent_2002.02.07.03.15.56.970/
no_responseEvent_2002.02.10.01.47.07.450/
no_responseEvent_2002.02.13.14.18.46.00/
각 파일 이름에서 'no_response'를 제거하고 싶습니다.
어떻게하나요?
for 루프가 작동 할 수 있다는 것을 알고 있지만 구현 방법에 대해 혼란 스럽습니다.
250 개의 파일이 모두 동일한 디렉토리에 있고 동일한 이름 지정 패턴을 따른다고 가정합니다. 그렇다면 할 수 있습니다.
for i in "$remove"*;do mv "$i" "${i#"$remove"}";done
테스팅
ls
no_responseEvent_2002.02.07.03.15.56.970
no_responseEvent_2002.02.07.03.15.56.972
no_responseEvent_2002.02.07.03.15.56.971
no_responseEvent_2002.02.07.03.15.56.973
이제 for
루프를 실행 한 후 출력을 다음과 같이 얻습니다.
remove=no_response
for i in "$remove"*;do mv "$i" "${i#"$remove"}";done
ls
Event_2002.02.07.03.15.56.970
Event_2002.02.07.03.15.56.971
Event_2002.02.07.03.15.56.972
Event_2002.02.07.03.15.56.973
참고 문헌
http://www.commandlinefu.com/commands/view/2519/uniformly-correct-filenames-in-a-directory
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다