On Mon, 6 Nov 2006, Indunil Jayasooriya wrote: > Hi All, > > I want to know how to grep and delete (remove) files . > > What I need is that there are some unwanted out going mails in the queue in > my Centos 4.4 Sendmail Server. I can find them with the below commad. > > mailq /var/spool/mqueue/ |grep '<>' > > Then It displays all the mails of that type withg their ids in the following > way. > > [root at gateway ~]# mailq /var/spool/mqueue/ |grep '<>' > kA63ZwJT007450 13864 Mon Nov 6 09:05 <> [root at gateway ~]# mailq /var/spool/mqueue/ |grep '<>' | awk '{print $1}' | xargs rm -f you could eliminate the grep by using awk's pattern matching, but will have to figure out the escapes. Can also replace awk with sed, perl or cut. ------------------------------------------------------------------------ Jim Wildman, CISSP, RHCE jim at rossberry.com http://www.rossberry.com "Society in every state is a blessing, but Government, even in its best state, is a necessary evil; in its worst state, an intolerable one." Thomas Paine