파일이 복사되지 않는 이유를 알 수 없습니다

파일이 복사되지 않는 이유를 알 수 없습니다

콘텐츠를 여러 디렉터리에 복사하는 데 재사용할 수 있는 프로그램을 작성하려고 합니다. 하지만 평생 동안 프로그램이 작동하지 않고 이 오류가 발생하는 이유를 알 수 없습니다.

복사해야 하는 폴더 이름이 포함된 파일이 있습니다.

test1
test2
test3

다음 명령을 사용하여 위의 각 폴더에 default.meta라는 파일을 복사하려고 합니다.

while read $line;
do 
cp -r default.meta $line;
done < test

명령을 실행하면 다음 오류가 발생하며 평생 동안 이것이 작동하지 않는 이유를 알 수 없습니다.

cp: missing destination file operand after ‘default.meta’
Try 'cp --help' for more information.
cp: missing destination file operand after ‘default.meta’
Try 'cp --help' for more information.
cp: missing destination file operand after ‘default.meta’
Try 'cp --help' for more information.
cp: missing destination file operand after ‘default.meta’
Try 'cp --help' for more information.

내가 여기서 무엇을 놓치고 있는 걸까요?

답변1

따라서 이전 설명에 따라 "line" 변수에 빈 값을 지정했습니다. 읽어야 해

while read line; do  cp -r ./default.meta "$line"; done < test 

관련 정보