-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On Fri, Sep 02, 2005 at 09:00:22AM -0500, Jerry Geis wrote:
I am trying to use cut to tell me the suffix of a file. for example: echo /home/silentm/log/file.machine.log | cut -d . -f 1-
I was expecting to get .log or log but I get the entire string echoed back.
doing the opposite gave me what I expected: echo /home/silentm/log/file.machine.log | cut -d . -f 1 gives me /home/silentm/log/file
echo /home/silentm/log/file.machine.log | sed 's/^.*.([^.]*)$/\1/'
Will work all the time.
/home/silentm/log/file.machine.log --> log /home/silentm/log/file.machine.log.1.2.3.4 --> 4
If you want to get the dot too, just use 's/^.*(.[^.]*)$/\1/' instead.
Best Regards,
- -- Rodrigo Barbosa rodrigob@suespammers.org "Quid quid Latine dictum sit, altum viditur" "Be excellent to each other ..." - Bill & Ted (Wyld Stallyns)