~archive
과 동일한 디렉토리에있는 파일 묶음에서 #archive
문자열을 대체하려고합니다. 내 파일 이름에는 공백이 있고 오히려 길다. 나는 점검했고 누군가는 -0과 함께 -Z와 xargs를 사용하여 grep을 호출해야한다고 말했다. 그래서 나는 그렇게했다. OSX에서 grep 및 sed로 찾기 및 바꾸기
sed: /Users/bobthebuilder/dropbox/documents/notes/Archive/20130824_1553_I_Kino Interesting Books.txt
/Users/bobthebuilder/dropbox/documents/notes/Archive/20131003_1011_R_ExpensesOct13.txt
/Users/bobthebuilder/dropbox/documents/notes/Archive/20131111_1205_RI_SocialConnect.txt
/Users/bobthebuilder/dropbox/documents/notes/Archive/20131111_2233_I_GymNov13Dec13.txt
/Users/bobthebuilder/dropbox/documents/notes/Archive/20131112_1121_I_LifeChallenge.txt
/Users/bobthebuilder/dropbox/documents/notes/Archive/20131112_1242__PaperlessLiving.txt
/Users/bobthebuilder/dropbox/documents/notes/Archive/20131112_1243__Polymath.txt
/Users/bobthebuilder/dropbox/documents/notes/Archive/20131112_1327__ORDPlanning.txt
/Users/bobthebuilder/dropbox/documents/notes/Archive/20131124_1126__YunheProjectExcel.txt
/Users/bobthebuilder/dropbox/documents/notes/Archive/Contact Information.txt
/Users/bobthebuilder/dropbox/documents/notes/Archive/Excruciatingly Useful Shortcuts.txt
/Users/bobthebuilder/dropbox/documents/notes/Archive/How does this thing work?.txt
/Users/bobthebuilder/dropbox/documents/notes/Archive/Mail Migration.txt
/Users/bobthebuilder/dropbox/documents/notes/Archive/Markdownify.txt
/Users/bobthebuilder/dropbox/documents/notes/Archive/This is the title of a note.txt
: File name too long
그리고 아무것도
를 교체 할 때 :grep -lZ '#archive' ~/dropbox/documents/notes/Archive/* | xargs -0 sed -i "" 's|#archive|~archive|g'
은 내가 얻을 출력은 이것이다 :
내가 가진 현재 터미널 명령
이있다.는 또한 시도 :
| => grep -l --null '#archive' ~/dropbox/documents/notes/Archive/* | xargs -0 sed -i "" 's|#archive|~archive|g'
sed: RE error: illegal byte sequence
도움을 주시면 감사하겠습니다! 당신이 sed
의 -i
인수를 사용하고자하는 경우 파일이 동일한 폴더
sed -i "" 's/#archive/~archive/' ~/dropbox/documents/notes/Archive/*
감사! 분명히 ~/.bash_profile에 또 다른 문제가있어서'sed : RE error : illegal byte sequence'가 발생했습니다. 내 bash_profile에'export LC_CTYPE = C export LANG = C'를 추가했는데 그 후에 코드가 훌륭하게 작동했습니다! – chronologos