원격 Raspberry Pi 4b의 디렉터리 내의 모든 파일을 원격으로 업데이트하는 프로그램을 작성하려고 합니다. 나는 디렉토리에 있어야 하는 파일의 이름을 알고 있으며 이 이름은 절대 변경되지 않습니다. a la: 명령이 유지하려는 특정 파일을 건너뛰는 예를 본 적이 있지만
mv * !(filetostay) /destination
건너뛰려는 파일이 여러 개 있을 때 이를 실행할 수 있는 방법이 있습니까? 게다가 파일이 알파벳순이나 제가 생각할 수 있는 다른 방식으로 연속되지 않고 파일 이름만 알고 있습니다.
다음을 실행해 보았습니다.
shopt -s extglob
mv * !(file1|file2) destination
그러나 RPi는 말한 대로 구문을 좋아하지 않습니다.
mv: cannot move 'destination' to a subdirectory of itself, 'destination/destination'
mv: warning: source directory 'destination' specified more than once
mv: cannot stat 'file1': No such file or directory
mv: cannot stat 'file2': No such file or directory
답변1
노력하다
mv !(file1|file2) destination
추가 별표는 pwd에 숨겨져 있지 않은 모든 파일의 목록을 의미합니다.