.out
다음은 및 .class
파일을 제외한 모든 파일을 이라는 하위 디렉터리에 복사하려는 시도입니다 homework21/
. Note는 homework21
제가 작업 중인 폴더의 하위 디렉터리입니다.
me@ice4:~/pset2$ find . -type f ! '(' -name '*.out' -o -name '*.class' ')'
./PartB.txt
./DooBee.java
./Prob8.java
./Diamond.java
./Prob10.java
./Prob11.java
./Drawing.java
./typescript
me@ice4:~/pset2$ find . -type f ! '(' -name '*.out' -o -name '*.class' ')' -exec cp -r homework21/. {} \;
cp: cannot overwrite non-directory `./PartB.txt' with directory `homework21/.'
cp: cannot overwrite non-directory `./DooBee.java' with directory `homework21/.'
cp: cannot overwrite non-directory `./Prob8.java' with directory `homework21/.'
cp: cannot overwrite non-directory `./Diamond.java' with directory `homework21/.'
cp: cannot overwrite non-directory `./Prob10.java' with directory `homework21/.'
cp: cannot overwrite non-directory `./Prob11.java' with directory `homework21/.'
cp: cannot overwrite non-directory `./Drawing.java' with directory `homework21/.'
cp: cannot overwrite non-directory `./typescript' with directory `homework21/.'
me@ice4:~/pset2$ ls homework21/
me@ice4:~/pset2$ find . -type f ! '(' -name '*.out' -o -name '*.class' ')' -exec cp homework21/. {} \;
cp: omitting directory `homework21/.'
cp: omitting directory `homework21/.'
cp: omitting directory `homework21/.'
cp: omitting directory `homework21/.'
cp: omitting directory `homework21/.'
cp: omitting directory `homework21/.'
cp: omitting directory `homework21/.'
cp: omitting directory `homework21/.'
me@ice4:~/pset2$ ls homework21/
me@ice4:~/pset2$ find . -type f ! '(' -name '*.out' -o -name '*.class' ')' -exec cp homework21/ {} \;
cp: omitting directory `homework21/'
cp: omitting directory `homework21/'
cp: omitting directory `homework21/'
cp: omitting directory `homework21/'
cp: omitting directory `homework21/'
cp: omitting directory `homework21/'
cp: omitting directory `homework21/'
cp: omitting directory `homework21/'
me@ice4:~/pset2$ find . -type f ! '(' -name '*.out' -o -name '*.class' ')' -exec cp -r homework21/ {} \;
cp: cannot overwrite non-directory `./PartB.txt' with directory `homework21/'
cp: cannot overwrite non-directory `./DooBee.java' with directory `homework21/'
cp: cannot overwrite non-directory `./Prob8.java' with directory `homework21/'
cp: cannot overwrite non-directory `./Diamond.java' with directory `homework21/'
cp: cannot overwrite non-directory `./Prob10.java' with directory `homework21/'
cp: cannot overwrite non-directory `./Prob11.java' with directory `homework21/'
cp: cannot overwrite non-directory `./Drawing.java' with directory `homework21/'
cp: cannot overwrite non-directory `./typescript' with directory `homework21/'
왜 이것이 작동하지 않습니까?
답변1
cp 명령의 구문은 다음과 같습니다.
cp source target
따라서 다음 find
명령을 사용하십시오.
find . -type f ! '(' -name '*.out' -o -name '*.class' ')' -exec cp -v {} homework21/ \;
디렉터리가 아닌 파일만 복사하므로 -r
in 플래그는 필요 하지 않습니다. 내용이 길었다고 cp
덧붙였습니다 .-v
cp