ls
을 실행할 때 다음을 참조하십시오. 나는 새로운 라인 다음 코드는 $i
for i in $(ls | grep -F "Screen Shot"); do rm $i; done
grep이 출력되는 곳에 새로운 줄을 유지하십시오.
shot
파일 screen
을 찾으려고
에 Screen Shot..
10-15
BashStorage
blah.csv
LockScreen.app
NetsuiteBFN
Screen Shot 2017-10-26 at 11.09.08 AM.png
Screen Shot 2017-11-02 at 12.24.13 PM.png
Screen Shot 2017-11-10 at 9.20.33 AM.png
Screen Shot 2017-11-10 at 9.21.29 AM.png
Screen Shot 2017-11-20 at 10.26.24 AM.png
Screen Shot 2017-11-20 at 10.29.18 AM.png
Screen Shot 2017-11-20 at 10.30.40 AM.png
Screen Shot 2017-11-20 at 10.31.55 AM.png
Screen Shot 2017-11-20 at 10.34.11 AM.png
Screen Shot 2017-11-20 at 10.55.34 AM.png
Screen Shot 2017-11-20 at 10.56.44 AM.png
Screen Shot 2017-11-20 at 10.56.54 AM.png
Screen Shot 2017-11-20 at 10.59.20 AM.png
finalResourceUrls.txt
good
lockScreen
lockScreen.zip
ls.txt
x
ls | grep -F 'Screen Shot'
반환의 스크린 샷 항목을 각각 모든 인스턴스를 삭제하려면
이고 구분 기호로 space
을 사용하므로 실패합니다.
은 또한 표준 출력 터미널 때 그렙 새로운 라인을 인쇄하는 것으로 관찰되지만 I 파일로 재지시 I 가변 출력을 설정하면, 새로운 라인은 더 없다, (ls | grep -F "Screen Shot") > shots.txt
그러나 을 유지 새로운 라인
shots="$(ls | grep -F "Screen Shot")"
Screen Shot 2017-10-26 at 11.09.08 AM.png Screen Shot 2017-11-02 at 12.24.13 PM.png Screen Shot 2017-11-10 at 9.20.33 AM.png Screen Shot 2017-11-10 at 9.21.29 AM.png Screen Shot 2017-11-20 at 10.26.24 AM.png Screen Shot 2017-11-20 at 10.30.40 AM.png Screen Shot 2017-11-20 at 10.31.55 AM.png Screen Shot 2017-11-20 at 7.01.32 PM.png Screen Shot 2017-11-21 at 11.49.15 AM.png
- 어떻게 스크린 샷 항목과 드 반복 않습니다 그들을 불러요?
- grep에서 새 라인을 유지하려면 어떻게해야합니까?
편집 : 사이러스는 여전히
'rm Screen \ Shot \ *'또는'rm "스크린 샷"* "? – Cyrus
@Cyrus 감사합니다! 그게 효과가 있었지만 grep이 작동하는 방식에 관심이 많아서 여기에 질문을 남겨 둘 것입니다. – Goldfish
Btw :: [왜 * l *을 파싱하지 않습니까?] (http://unix.stackexchange.com/questions/128985)/why-not-parse-ls) – Cyrus