[CentOS] question on cut
Mark Belanger
mark_belanger at ltx.comFri Sep 2 14:23:30 UTC 2005
- Previous message: [CentOS] question on cut
- Next message: [CentOS] question on cut
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
>
> I am trying to find a way to test if the file ends in .log?
Awk will do it:
# echo /home/silentm/log/file.machine.log | awk -F. '{print $NF}'
log
The benefit of awk is that you don't have to know how
many dots are in the file. $NF just prints the last one.
-Mark
--
Mark Belanger
LTX Corporation
- Previous message: [CentOS] question on cut
- Next message: [CentOS] question on cut
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the CentOS mailing list