AWK doubt
am 27.05.2007 14:07:15 von apogeusistemas
Hi:
Can you explain me why command below fail ?
(Doesn=B4t catch error 41 in file jobs4.lis)
Solaris> cat jobs4.lis | grep -i "`date +%m/%d/07`" | awk 'substr($0,
50, 4) + 0 > 1'
Solaris>
Solaris> cat jobs4.lis
207245 WIN_DIARIO_23 Backup Done 0 05/26/07 23:00
05/27/07 05:54 006:19:04 UCMTZS2K055 2537 F 0
207244 WIN_DIARIO_23 Backup Done 0 05/26/07 23:00
05/27/07 08:34 009:06:12 TUMTZS2K050 3047 F 0
207243 WIN_DIARIO_23 Backup Done 0 05/26/07 23:00
05/27/07 07:42 008:42:44 OXMTZS2K036 2816 F 0
207241 WIN_DIARIO_23 Backup Waiting-t 41 05/26/07
23:00 009:52:26 OXMTZS2K3057 0 F 0
207240 WIN_DIARIO_23 Backup Waiting-t 41 05/26/07
23:00 009:52:27 OXMTZS2K3058 0 F 0
207239 WIN_DIARIO_23 Backup Waiting-t 41 05/26/07
23:00 009:52:29 SMMTZS2K3115 0 F 0
207238 ORA_LX002_CORP_ON Backup Done 0 05/26/07 22:58
05/26/07 23:37 000:38:25 smmtzslx002 41126 A 0
207236 WIN_DIARIO_21 Backup Done 0 05/26/07 22:50
05/27/07 01:14 002:23:48 OXMTZS2K3030 2741 F 0
207235 WIN_DIARIO_21 Backup Done 1 05/26/07 22:49
05/27/07 02:06 003:16:48 OXMTZS2K3081 2713 F 0
207234 WIN_DIARIO_21 Backup Done 1 05/26/07 22:44
05/27/07 01:40 002:55:48 OXMTZS2K3074 2723 F 0
Thanks
Re: AWK doubt
am 27.05.2007 14:32:43 von Janis Papanagnou
apogeusistemas@gmail.com wrote:
> Hi:
> Can you explain me why command below fail ?
Because you started the program today, but the logfile entry would match
only the date yesterday?
Your program works for me (with dates adjusted).
> (Doesn´t catch error 41 in file jobs4.lis)
>
> Solaris> cat jobs4.lis | grep -i "`date +%m/%d/07`" | awk 'substr($0,
> 50, 4) + 0 > 1'
BTW, cat is unnecessary and -i is unnecessary and grep can be done by awk.
awk -v d=$(date +'%m/%d/07') '$0~d && substr($0,50, 4) + 0 > 1' jobs4.lis
Also, if there are no whitespace characters in any of the first four
fields you can as well compare against the fields (instead of substring)
awk -v d=$(date +'%m/%d/07') '$0 ~ d && $5 > 1' jobs4.lis
Janis
> Solaris>
>
> Solaris> cat jobs4.lis
>
> 207245 WIN_DIARIO_23 Backup Done 0 05/26/07 23:00
> 05/27/07 05:54 006:19:04 UCMTZS2K055 2537 F 0
> 207244 WIN_DIARIO_23 Backup Done 0 05/26/07 23:00
> 05/27/07 08:34 009:06:12 TUMTZS2K050 3047 F 0
> 207243 WIN_DIARIO_23 Backup Done 0 05/26/07 23:00
> 05/27/07 07:42 008:42:44 OXMTZS2K036 2816 F 0
> 207241 WIN_DIARIO_23 Backup Waiting-t 41 05/26/07
> 23:00 009:52:26 OXMTZS2K3057 0 F 0
> 207240 WIN_DIARIO_23 Backup Waiting-t 41 05/26/07
> 23:00 009:52:27 OXMTZS2K3058 0 F 0
> 207239 WIN_DIARIO_23 Backup Waiting-t 41 05/26/07
> 23:00 009:52:29 SMMTZS2K3115 0 F 0
> 207238 ORA_LX002_CORP_ON Backup Done 0 05/26/07 22:58
> 05/26/07 23:37 000:38:25 smmtzslx002 41126 A 0
> 207236 WIN_DIARIO_21 Backup Done 0 05/26/07 22:50
> 05/27/07 01:14 002:23:48 OXMTZS2K3030 2741 F 0
> 207235 WIN_DIARIO_21 Backup Done 1 05/26/07 22:49
> 05/27/07 02:06 003:16:48 OXMTZS2K3081 2713 F 0
> 207234 WIN_DIARIO_21 Backup Done 1 05/26/07 22:44
> 05/27/07 01:40 002:55:48 OXMTZS2K3074 2723 F 0
>
>
> Thanks
>
Re: AWK doubt
am 27.05.2007 14:36:19 von Janis Papanagnou
apogeusistemas@gmail.com wrote:
> Hi:
> Can you explain me why command below fail ?
> (Doesn´t catch error 41 in file jobs4.lis)
>
> Solaris> cat jobs4.lis | grep -i "`date +%m/%d/07`" | awk 'substr($0,
> 50, 4) + 0 > 1'
Ah! Wait...
> Solaris>
Have you tried one of the other solaris awk's (e.g. /usr/xpg4/bin/awk)?
Janis
>
> Solaris> cat jobs4.lis
>
> 207245 WIN_DIARIO_23 Backup Done 0 05/26/07 23:00
> 05/27/07 05:54 006:19:04 UCMTZS2K055 2537 F 0
> 207244 WIN_DIARIO_23 Backup Done 0 05/26/07 23:00
> 05/27/07 08:34 009:06:12 TUMTZS2K050 3047 F 0
> 207243 WIN_DIARIO_23 Backup Done 0 05/26/07 23:00
> 05/27/07 07:42 008:42:44 OXMTZS2K036 2816 F 0
> 207241 WIN_DIARIO_23 Backup Waiting-t 41 05/26/07
> 23:00 009:52:26 OXMTZS2K3057 0 F 0
> 207240 WIN_DIARIO_23 Backup Waiting-t 41 05/26/07
> 23:00 009:52:27 OXMTZS2K3058 0 F 0
> 207239 WIN_DIARIO_23 Backup Waiting-t 41 05/26/07
> 23:00 009:52:29 SMMTZS2K3115 0 F 0
> 207238 ORA_LX002_CORP_ON Backup Done 0 05/26/07 22:58
> 05/26/07 23:37 000:38:25 smmtzslx002 41126 A 0
> 207236 WIN_DIARIO_21 Backup Done 0 05/26/07 22:50
> 05/27/07 01:14 002:23:48 OXMTZS2K3030 2741 F 0
> 207235 WIN_DIARIO_21 Backup Done 1 05/26/07 22:49
> 05/27/07 02:06 003:16:48 OXMTZS2K3081 2713 F 0
> 207234 WIN_DIARIO_21 Backup Done 1 05/26/07 22:44
> 05/27/07 01:40 002:55:48 OXMTZS2K3074 2723 F 0
>
>
> Thanks
>
Re: AWK doubt
am 29.05.2007 15:14:38 von apogeusistemas
On 27 maio, 09:36, Janis Papanagnou
wrote:
> apogeusiste...@gmail.com wrote:
> > Hi:
> > Can you explain me why command below fail ?
> > (Doesn=B4t catch error 41 in file jobs4.lis)
>
> > Solaris> cat jobs4.lis | grep -i "`date +%m/%d/07`" | awk 'substr($0,
> > 50, 4) + 0 > 1'
>
> Ah! Wait...
>
> > Solaris>
>
> Have you tried one of the other solaris awk's (e.g. /usr/xpg4/bin/awk)?
>
> Janis
>
>
>
>
>
> > Solaris> cat jobs4.lis
>
> > 207245 WIN_DIARIO_23 Backup Done 0 05/26/07 23:00
> > 05/27/07 05:54 006:19:04 UCMTZS2K055 2537 F 0
> > 207244 WIN_DIARIO_23 Backup Done 0 05/26/07 23:00
> > 05/27/07 08:34 009:06:12 TUMTZS2K050 3047 F 0
> > 207243 WIN_DIARIO_23 Backup Done 0 05/26/07 23:00
> > 05/27/07 07:42 008:42:44 OXMTZS2K036 2816 F 0
> > 207241 WIN_DIARIO_23 Backup Waiting-t 41 05/26/07
> > 23:00 009:52:26 OXMTZS2K3057 0 F 0
> > 207240 WIN_DIARIO_23 Backup Waiting-t 41 05/26/07
> > 23:00 009:52:27 OXMTZS2K3058 0 F 0
> > 207239 WIN_DIARIO_23 Backup Waiting-t 41 05/26/07
> > 23:00 009:52:29 SMMTZS2K3115 0 F 0
> > 207238 ORA_LX002_CORP_ON Backup Done 0 05/26/07 22:58
> > 05/26/07 23:37 000:38:25 smmtzslx002 41126 A 0
> > 207236 WIN_DIARIO_21 Backup Done 0 05/26/07 22:50
> > 05/27/07 01:14 002:23:48 OXMTZS2K3030 2741 F 0
> > 207235 WIN_DIARIO_21 Backup Done 1 05/26/07 22:49
> > 05/27/07 02:06 003:16:48 OXMTZS2K3081 2713 F 0
> > 207234 WIN_DIARIO_21 Backup Done 1 05/26/07 22:44
> > 05/27/07 01:40 002:55:48 OXMTZS2K3074 2723 F 0
>
> > Thanks- Ocultar texto entre aspas -
>
> - Mostrar texto entre aspas -
Thank you , Janis !
Re: Awk Doubt
am 19.12.2007 15:15:25 von Ed Morton
On 12/17/2007 3:03 PM, apogeusistemas@gmail.com wrote:
> Hi:
> How could use awk to remove all ocurrences of "Average" in a file ?
>
> cat file
>
> 12/01/07 23:45:00 1 1 0 97
> 12/01/07 23:50:00 0 1 0 98
> 12/01/07 23:55:00 0 1 0 98
> 12/01/07 Average 7 2 0 90
>
> cat file | ./script
>
> 12/01/07 23:45:00 1 1 0 97
> 12/01/07 23:50:00 0 1 0 98
> 12/01/07 23:55:00 0 1 0 98
No need for awk:
grep -v Average file
Ed.
Re: Awk Doubt
am 20.12.2007 12:39:48 von mik3l3374
On Dec 18, 5:03 am, apogeusiste...@gmail.com wrote:
> Hi:
> How could use awk to remove all ocurrences of "Average" in a file ?
>
> cat file
>
> 12/01/07 23:45:00 1 1 0 97
> 12/01/07 23:50:00 0 1 0 98
> 12/01/07 23:55:00 0 1 0 98
> 12/01/07 Average 7 2 0 90
>
> cat file | ./script
>
> 12/01/07 23:45:00 1 1 0 97
> 12/01/07 23:50:00 0 1 0 98
> 12/01/07 23:55:00 0 1 0 98
not awk though
while read line
do
case $line in
*Average* ) continue ;;
*) echo $line;
esac
done < file