Return to BSD News archive
Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!news.mira.net.au!news.mel.connect.com.au!munnari.OZ.AU!news.ecn.uoknor.edu!qns3.qns.com!imci4!newsfeed.internetmci.com!in2.uu.net!news.mathworks.com!news2.mathworks.com!newscaster-1.mcast.net!cs.tu-berlin.de!zib-berlin.de!news.tu-chemnitz.de!irz401!uriah.heep!news From: j@uriah.heep.sax.de (J Wunsch) Newsgroups: comp.unix.bsd.freebsd.misc Subject: Re: [S]: Script Date: 27 May 1996 10:26:15 GMT Organization: Private BSD site, Dresden Lines: 54 Message-ID: <4oc007$6u0@uriah.heep.sax.de> References: <xorMtMD4F99aRz1@borki.zug.use.ch> Reply-To: joerg_wunsch@uriah.heep.sax.de (Joerg Wunsch) NNTP-Posting-Host: localhost.heep.sax.de Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Newsreader: knews 0.9.6 X-Phone: +49-351-2012 669 X-PGP-Fingerprint: DC 47 E6 E4 FF A6 E9 8F 93 21 E0 7D F9 12 D6 4E BORKI@zug.use.ch (Reto Burkhalter) wrote: > I'm looling for a shell script or command line syntax in > order to delete lines in a file with a specific content. > I want to delete member entries in a database without having > to invoke an editor. > > e.g. database file > > foo xxyy > bar yyzz > sec zzaa > > > %script <file> <entry> ; %script database foo -> deletes the > first entry (line) in the database. > > Who can help me?? Why don't you wanna use an editor? :) (This is, of course, untested, i hope i didn't forget anyhting.) #!/bin/sh usage() { echo "usage: $0 file entry" 1>&2 exit 1 } if [ $# -ne 2 ] ; then usage fi file=$1 entry=$2 if [ ! -f "$file" ] ; then echo "$0: $file not found" 1>&2 fi ed -s "$file" <<EOF /^$entry/d w q EOF -- cheers, J"org joerg_wunsch@uriah.heep.sax.de -- http://www.sax.de/~joerg/ -- NIC: JW11-RIPE Never trust an operating system you don't have sources for. ;-)