Redian新闻
>
如何删除一组文件或给一组文件更名?
avatar
如何删除一组文件或给一组文件更名?# Unix - 噫吁兮,危乎高哉
F*Q
1
比如find的结果中把一些文件删除,比如所有的a.out
还有用统配符好像mv不让:(
avatar
m*e
2
Open your eyes and look around in this board.

【在 F***Q 的大作中提到】
: 比如find的结果中把一些文件删除,比如所有的a.out
: 还有用统配符好像mv不让:(

avatar
F*Q
3
while, I have asked the question at 6757,but nobody seems
wonna hand

【在 m*****e 的大作中提到】
: Open your eyes and look around in this board.
avatar
c*t
4
Give you a hint. read man page of find.

【在 F***Q 的大作中提到】
: while, I have asked the question at 6757,but nobody seems
: wonna hand

avatar
F*Q
5
I got it,thx
but I still wonder how can I get the purpose by using ls as
ls -1 | grep mystr
which can list all of the files, then, how to delete them?
only can find exec another command?

【在 c*****t 的大作中提到】
: Give you a hint. read man page of find.
avatar
c*t
6
1. find could do the job as well :) Mastering find is invaluable.
2. Learn to use backquote.
rm `ls -1 | grep mystr`

【在 F***Q 的大作中提到】
: I got it,thx
: but I still wonder how can I get the purpose by using ls as
: ls -1 | grep mystr
: which can list all of the files, then, how to delete them?
: only can find exec another command?

avatar
t*l
7
I think this won't work. should be
rm `ls -1 | xargs grep -l mystr`
avatar
c*t
8
Mine lists filenames containing mystr.
Yours lists files in which the contents contain mystr.
Actually, ls -1 is completely unnecessary since * is
all one needs.

【在 t*********l 的大作中提到】
: I think this won't work. should be
: rm `ls -1 | xargs grep -l mystr`

avatar
m*e
9

You don't want to do that. Try to think simple:
rm -f *mystr*

【在 F***Q 的大作中提到】
: I got it,thx
: but I still wonder how can I get the purpose by using ls as
: ls -1 | grep mystr
: which can list all of the files, then, how to delete them?
: only can find exec another command?

avatar
F*Q
10
thanks all!:)

【在 m*****e 的大作中提到】
:
: You don't want to do that. Try to think simple:
: rm -f *mystr*

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。