Prev: Example of kill -9 erasing and/or corrupting a (temporary) file?
Next: wget -r (recursive) failing to back up a site
From: Michael Paoli on 25 Jun 2010 00:55 On Jun 7, 12:47 am, David Kirkby <drkirkby(a)gmail.com> wrote: > I think 'sed' is the tool for this, though I may be wrong. > > I have a list of files > > atlas-3.8.3.p12.spkg > blas-20070724.spkg > boehm_gc-7.1.p5.spkg > boost-cropped-1.34.1.spkg > cddlib-094f.p6.spkg > cephes-2.8.spkg > cliquer-1.2.p5.spkg > conway_polynomials-0.2.spkg > cvxopt-0.9.p8.spkg > cython-0.12.1.spkg > deps > docutils-0.5.p0.spkg > ecl-10.2.1.spkg > eclib-20080310.p10.spkg > > and would like to remove the hyphen and all characters after them. So > I get > > atlas > blas > boehm_gc > boost-cropped > cddlib > cephes > cliquer > conway_polynomials > > etc > > What's the best way to do this? > > I note 'deps' has no hypen, but I think that is the only such case and > can be handled manually if need be. There's about 100 of these, so > whilst doing them manually is not impossible, it's a bit tedious. > > Note I actually want to remove the hyphen, so the subject line is > slightly inaccurate, but any attempt I could think of to rewrite the > subject line in a more accurate form just got too wordy. In any case, > I know how to remove a hyphen easily. sed -e 's/-.*$//'
From: Rakesh Sharma on 25 Jun 2010 07:58
On Jun 7, 12:47 pm, David Kirkby <drkir...(a)gmail.com> wrote: > I think 'sed' is the tool for this, though I may be wrong. > > I have a list of files > > atlas-3.8.3.p12.spkg > blas-20070724.spkg > boehm_gc-7.1.p5.spkg > boost-cropped-1.34.1.spkg > cddlib-094f.p6.spkg > cephes-2.8.spkg > cliquer-1.2.p5.spkg > conway_polynomials-0.2.spkg > cvxopt-0.9.p8.spkg > cython-0.12.1.spkg > deps > docutils-0.5.p0.spkg > ecl-10.2.1.spkg > eclib-20080310.p10.spkg > > and would like to remove the hyphen and all characters after them. So > I get > > atlas > blas > boehm_gc > boost-cropped > cddlib > cephes > cliquer > conway_polynomials > > etc > > What's the best way to do this? > > I note 'deps' has no hypen, but I think that is the only such case and > can be handled manually if need be. There's about 100 of these, so > whilst doing them manually is not impossible, it's a bit tedious. > > Note I actually want to remove the hyphen, so the subject line is > slightly inaccurate, but any attempt I could think of to rewrite the > subject line in a more accurate form just got too wordy. In any case, > I know how to remove a hyphen easily. > > Dave cut -c'-' -f1 |