On Tue, 17 Sep 2002, Ashwin Khandare wrote:
> hi everybody
>
> Can anyone tell me how do I search and replace a pattern in file using shell(BASH).
>
> file abc.txt contains
> Sep 15 14:18:54 203.146.91.228:23 202.88.143.72:23
>
>
> The time 14:18:54 (hours:mins:secs) needs to be replaced by 14:18 (hours:mins) for
>"n" number of lines in a file
perl -pie 's/(\d\d:\d\d):\d\d/\1/' myfilename
If you really need to do it in bash, create a script "stripsecs.sh"
#!/bin/bash
while read inline
do
outline="${inline:0:12}${inline:15}"
echo "${outline}"
done
----------------------------------------------------------------------------
DDDD David Kramer [EMAIL PROTECTED] http://thekramers.net
DK KD
DKK D "Questions are a burden to others,
DK KD Answers a prison for oneself."
DDDD -The Prisoner
--
redhat-list mailing list
unsubscribe mailto:[EMAIL PROTECTED]?subject=unsubscribe
https://listman.redhat.com/mailman/listinfo/redhat-list