提问人:D.R 提问时间:9/19/2019 最后编辑:D.R 更新时间:9/20/2019 访问量:44
复制和粘贴命令时命令行中出现奇怪的重复/错误
Weird duplication/mistakes in command line when I copy and paste commands
问:
我有以下命令,当我单独运行它们时,它们会起作用。
find ./temp -name "Keller, Whitney" -type d | while read path ; do (cp -Rn "$path/" "/Users/oppeasnt/Desktop/RenameFoldersProject/Year_of_Entry_2016/Keller, Whitney_73618848766720/Student_Assignments/" ;) done ; find ./temp -name "Keller, Whitney" -type d | while read path ; do (cp -Rn "$path/" "/Users/oppeasnt/Desktop/RenameFoldersProject/temp/2016/Keller, Whitney_73618848766720/Student_Assignments/" ;) done ; cp -Rn "/Users/oppeasnt/Desktop/RenameFoldersProject/temp/2016/Keller, Whitney_73618848766720/Student_Documents" "/Users/oppeasnt/Desktop/RenameFoldersProject/Year_of_Entry_2016/Keller, Whitney_73618848766720/" ;
find ./temp -name "Kim, Christina" -type d | while read path ; do (cp -Rn "$path/" "/Users/oppeasnt/Desktop/RenameFoldersProject/Year_of_Entry_2016/Kim, Christina_73618848766722/Student_Assignments/" ;) done ; find ./temp -name "Kim, Christina" -type d | while read path ; do (cp -Rn "$path/" "/Users/oppeasnt/Desktop/RenameFoldersProject/temp/2016/Kim, Christina_73618848766722/Student_Assignments/" ;) done ; cp -Rn "/Users/oppeasnt/Desktop/RenameFoldersProject/temp/2016/Kim, Christina_73618848766722/Student_Documents" "/Users/oppeasnt/Desktop/RenameFoldersProject/Year_of_Entry_2016/Kim, Christina_73618848766722/" ;
find ./temp -name "Kim, Daniel" -type d | while read path ; do (cp -Rn "$path/" "/Users/oppeasnt/Desktop/RenameFoldersProject/Year_of_Entry_2016/Kim, Daniel_73618848766721/Student_Assignments/" ;) done ; find ./temp -name "Kim, Daniel" -type d | while read path ; do (cp -Rn "$path/" "/Users/oppeasnt/Desktop/RenameFoldersProject/temp/2016/Kim, Daniel_73618848766721/Student_Assignments/" ;) done ; cp -Rn "/Users/oppeasnt/Desktop/RenameFoldersProject/temp/2016/Kim, Daniel_73618848766721/Student_Documents" "/Users/oppeasnt/Desktop/RenameFoldersProject/Year_of_Entry_2016/Kim, Daniel_73618848766721/" ;
find ./temp -name "Kim, Eunice" -type d | while read path ; do (cp -Rn "$path/" "/Users/oppeasnt/Desktop/RenameFoldersProject/Year_of_Entry_2016/Kim, Eunice_73618848767724/Student_Assignments/" ;) done ; find ./temp -name "Kim, Eunice" -type d | while read path ; do (cp -Rn "$path/" "/Users/oppeasnt/Desktop/RenameFoldersProject/temp/2016/Kim, Eunice_73618848767724/Student_Assignments/" ;) done ; cp -Rn "/Users/oppeasnt/Desktop/RenameFoldersProject/temp/2016/Kim, Eunice_73618848767724/Student_Documents" "/Users/oppeasnt/Desktop/RenameFoldersProject/Year_of_Entry_2016/Kim, Eunice_73618848767724/" ;
find ./temp -name "Kim, Rebecca" -type d | while read path ; do (cp -Rn "$path/" "/Users/oppeasnt/Desktop/RenameFoldersProject/Year_of_Entry_2016/Kim, Rebecca_73618848766723/Student_Assignments/" ;) done ; find ./temp -name "Kim, Rebecca" -type d | while read path ; do (cp -Rn "$path/" "/Users/oppeasnt/Desktop/RenameFoldersProject/temp/2016/Kim, Rebecca_73618848766723/Student_Assignments/" ;) done ; cp -Rn "/Users/oppeasnt/Desktop/RenameFoldersProject/temp/2016/Kim, Rebecca_73618848766723/Student_Documents" "/Users/oppeasnt/Desktop/RenameFoldersProject/Year_of_Entry_2016/Kim, Rebecca_73618848766723/" ;
但是,当我将所有 5 个复制并粘贴到我的命令行中(突出显示所有 5 个、command-C、command-V)时,命令行如下所示:
D-XXX-XX-XXX-XXX:renameFoldersProject oppeasnt$ find ./temp -name "Keller, Whitney" -type d | while read path ; do (cp -Rn "$path/" "/Users/oppeasnt/Desktop/RenameFoldersProject/Year_of_Entry_2016/Keller, Whitney_73618848766720/Student_Assignments/" ;) done ; find ./temp -name "Keller, Whitney" -type d | while read path ; do (cp -Rn "$path/" "/Users/oppeasnt/Desktop/RenameFoldersProject/temp/2016/Keller, Whitney_73618848766720/Student_Assignments/" ;) done ; cp -Rn "/Users/oppeasnt/Desktop/RenameFoldersProject/temp/2016/Keller, Whitney_73618848766720/Student_Documents" "/Users/oppeasnt/Desktop/RenameFoldersProject/Year_of_Entry_2016/Keller, Whitney_73618848766720/" ;
find ./temp -name "Kim, Christina" -type d | while read path ; do (cp -Rn "$path/" "/Users/oppeasnt/Desktop/RenameFoldersProject/Year_of_Entry_2016/Kim, Christina_73618848766722/Student_Assignments/" ;) done ; find ./temp -name "Kim, Christina" -type d | while read path ; do (cp -Rn "$path/" "/Users/oppeasnt/Desktop/RenameFoldersProject/temp/2016/Kim, Christina_73618848766722/Student_Assignments/" ;) done ; cp -Rn "/Users/oppeasnt/Desktop/RenameFoldersProject/temp/2016/Kim, Christina_73618848766722/Student_Documents" "/Users/oppeasnt/Desktop/RenameFoldersProject/Year_of_Entry_2016/Kim, Christina_73618848766722/" ;
find ./temp -name "Kim, Daniel" -type d | while read path ; do (cp -Rn "$path/" "/Users/oppeasnt/Desktop/RenameFoldersProject/Year_of_Entry_2016/Kim, Daniel_73618848766721/Student_Assignments/" ;) done ; find ./temp -name "Kim, Daniel" -type d | while read path ; do (cp -Rn "$path/" "/Users/oppeasnt/Desktop/RenameFoldersProject/temp/2016/Kim, Daniel_73618848766721/Student_Assignments/" ;) done ; D-XXX-XX-XXX-XXX:renameFoldersProject oppeasnt$ find ./temp -name "Kim, Christina" -type d | while read path ; do (cp -Rn "$path/" "/Users/oppeasnt/Desktop/RenameFoldersProject/Year_of_Entry_2016/Kim, Christina_73618848766722/Student_Assignments/" ;) done ; find ./temp -name "Kim, Christina" -type d | while readt/Desktop/RenameFoldersProject/temp/2016/Kim, Christina_73618848766722/Student_Assignments/" ;) done ; cp -Rn "/Users/oppeasnt/Desktop/RenameFoldersProject/temp/2016/Kim, Christina_73618848766722/Student_Documents" "/Users/oppeasnt/Desktop/RenameFoldersProject/Year_of_Entry_2016/Kim, Christina_73618848766722/" ;
find ./temp -name "Kim, Daniel" -type d | while read path ; do (cp -Rn "$path/" "/Users/oppeasnt/Desktop/RenameFoldersProject/Year_of_Entry_2016/Kim, Daniel_73618848766721/Student_Assignments/" ;) done ; find ./temp -name "Kim, Daniel" -type d | while read path ; do (cp -Rn "$path/" "/Users/oppeasnt/Desktop/RenameFoldersProject/temp/2016/Kim, Daniel_73618848766721/Student_Assignments/" ;) done ; cpfiRn "/Users/oppeasnt/Desktop/RenameFoldersProject/temp/2016/Kim, Daniel_73618848766721/Student_Documents" "/Users/oppeasnt/Desktop/RenameFoldersProject/Year_of_Entry_2016/Kim, Daniel_73618848766721/" ;
find ./temp -name "Kim, Eunice" -type d | while read path ; do (cp -Rn "$path/" "/Users/oppeasnt/Desktop/RenameFoldersProject/Year_of_Entry_2016/Kim, Eunice_73618848767724/Student_Assignments/" ;) done ; find ./temp -name "Kim, Eunice" -type d | while read path ; do (cp -Rn "$path/" "/Users/oppeasnt/Desktop/RenameFoldersProject/temp/2016/Kim, Eunice_73618848767724/Student_Assignments/" ;) done ; cp -Rn "/Users/oppD-XXX-XX-XXX-XXX:renameFoldersProject oppeasnt$ find ./temp -name "Kim, Daniel" -type d | while read path ; do (cp -Rn "$path/" "/Users/oppeasnt/Desktop/RenameFoldersProject/Year_of_Entry_2016/Kim, Daniel_73618848766721/Student_Assignments/" ;) done ; find ./temp -name "Kim, Daniel" -type d | w/RenameFoldersProject/temp/2016/Kim, Daniel_73618848766721/Student_Assignments/" ;) done ; cpfiRn "/Users/oppeasnt/Desktop/RenameFoldersProject/temp/2016/Kim, Daniel_73618848766721/Student_Documents" "/Users/oppeasnt/Desktop/RenameFoldersProject/Year_of_Entry_2016/Kim, Daniel_73618848766721/" ;
find ./temp -name "Kim, Eunice" -type d | while read path ; do (cp -Rn "$path/" "/Users/oppeasnt/Desktop/RenameFoldersProject/Year_of_Entry_2016/Kim, Eunice_73618848767724/Student_Assignments/" ;) done ; find ./temp -name "Kim, Eunice" -type d | while read path ; do (cp -Rn "$path/" "/Users/oppeasnt/Desktop/RenameFoldersProject/temp/2016/Kim, Eunice_73618848767724/Student_Assignments/" ;) done ; cp -Rn "/Users/oppeafind ./ktop/RenameFoldersProject/temp/2016/Kim, Eunice_73618848767724/Student_Documents" "/Users/oppeasnt/Desktop/RenameFoldersProject/Year_of_Entry_2016/Kim, Eunice_73618848767724/" ;
find ./temp -name "Kim, Rebecca" -type d | while read path ; do (cp -Rn "$path/" "/Users/oppeasnt/Desktop/RenameFoldersProject/Year_of_Entry_2016/Kim, Rebecca_73618848766723/Student_Assignments/" ;) done ; find ./temp -name "Kim, Rebecca" -type d | while read path ; do (cp -Rn "$path/" "/Users/oppeasnt/Desktop/RenameFoldersProject/temp/2016/Kim, Rebecca_73618848766723/Student_Assignments/" ;) done ; cp -Rn "/Users-bash: cpfiRn: command not found
D-XXX-XX-XXX-XXX:renameFoldersProject oppeasnt$ find ./temp -name "Kim, Eunice" -type d | while read path ; do (cp -Rn "$path/" "/Users/oppeasnt/Desktop/RenameFoldersProject/Year_of_Entry_2016/Kim, Eunice_73618848767724/Student_Assignments/" ;) done ; find ./temp -name "Kim, Eunice" -type d | while read path ; do (cp -Rn "$path/" "/Users/oppeasnt/Desktop/RenameFoldersProject/temp/2016/Kim, Eunice_73618848767724/Student_Assignments/" ;) done ; cp -Rn "/Users/oppeafind ./ktop/RenameFoldersProject/temp/2016/Kim, Eunice_73618848767724/Student_Documents" "/Users/oppeasnt/Desktop/RenameFoldersProject/Year_of_Entry_2016/Kim, Eunice_73618848767724/" ;
find ./temp -name "Kim, Rebecca" -type d | while read path ; do (cp -Rn "$path/" "/Users/oppeasnt/Desktop/RenameFoldersProject/Year_of_Entry_2016/Kim, Rebecca_73618848766723/Student_Assignments/" ;) done ; find ./temp -name "Kim, Rebecca" -type d | while read path ; do (cp -Rn "$path/" "/Users/oppeasnt/Desktop/RenameFoldersProject/temp/2016/Kim, Rebecca_73618848766723/Student_Assignments/" ;) done ; cp -Rn "/Users/oppeasnt/Desktop/RenameFoldersProject/temp/2016/Kim, Rebecca_73618848766723/Student_Documents" "/Users/oppeasnt/Desktop/RenameFoldersProject/Year_of_Entry_2016/Kim, Rebecca_73618848766723/" ; cp: /Users/oppeafind ./ktop/RenameFoldersProject/temp/2016/Kim, Eunice_73618848767724/Student_Documents: No such file or directory
D-XXX-XX-XXX-XXX:renameFoldersProject oppeasnt$ find ./temp -name "Kim, Rebecca" -type d | while read path ; do (cp -Rn "$path/" "/Users/oppeasnt/Desktop/RenameFoldersProject/Year_of_Entry_2016/Kim, Rebecca_73618848766723/Student_Assignments/" ;) done ; find ./temp -name "Kim, Rebecca" -type d | while read path ; do (cp -Rn "$path/" "/Users/oppeasnt/Desktop/RenameFoldersProject/temp/2016/Kim, Rebecca_73618848766723/Student_Assignments/" ;) done ; cp -Rn "/Users/oppeasnt/Desktop/RenameFoldersProject/temp/2016/Kim, Rebecca_73618848766723/Student_Documents" "/Users/oppeasnt/Desktop/RenameFoldersProject/Year_of_Entry_2016/Kim, Rebecca_73618848766723/" ;
您可以看到有些行是重复的,并且比我的原始命令要长得多。
如果向右滚动更多,则会看到类似以下内容
cp -Rn "/Users/oppD-XXX-XX-XXX-XXX:renameFoldersProject oppeasnt$
或
cp -Rn "/Users/oppeafind ./ktop/RenameFoldersProject/temp/2016/Kim, Eunice_73618848767724/Student_Documents
看起来像不同命令之间的冲突/重叠。
为什么会这样?我该如何解决这个问题?
答: 暂无答案
评论
source /path/to/script
.
. /path/to/script
/path/to/script
/path/to/script
if /path/to/script ; then echo script exited OK ; else echo error running script ; fi
if
else
find
find
> /tmp/myFindLog.txt; > /tmp/myFindErrs.txt
>> /tmp/myFindLog.txt 2>>/tmp/myFindErrs.txt
find
ls -l /tmp/myFind*
cp -Rn ...
cp -Rn...s
screen
screen