Command to extract saturdays and sundays

Command to extract saturdays and sundays

am 22.12.2007 15:51:23 von apogeusistemas

Hi:

I=B4m looking for a command to show me all saturdays and sundays in a
specified month. I create this command using awk, but awk change "cal"
output:

# cal 11 2007 | awk '{ print $1,
$7 }'
November
S S
1
4 10
11 17
18 24
25


# cal 11
2007
November 2007
S M Tu W Th F S
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30

# cal 11 2007 | awk '{ print $1, $2, $3, $4, $5,
$6,$7 }'
November 2007
S M Tu W Th F S
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30


Thanks for your help.

Re: Command to extract saturdays and sundays

am 22.12.2007 16:01:39 von Janis Papanagnou

apogeusistemas@gmail.com wrote:
> Hi:
>
> I´m looking for a command to show me all saturdays and sundays in a
> specified month. I create this command using awk, but awk change "cal"
> output:
>
> # cal 11 2007 | awk '{ print $1,
> $7 }'
> November
> S S
> 1
> 4 10
> 11 17
> 18 24
> 25
>
>
> # cal 11
> 2007
> November 2007
> S M Tu W Th F S
> 1 2 3
> 4 5 6 7 8 9 10
> 11 12 13 14 15 16 17
> 18 19 20 21 22 23 24
> 25 26 27 28 29 30
>
> # cal 11 2007 | awk '{ print $1, $2, $3, $4, $5,
> $6,$7 }'
> November 2007
> S M Tu W Th F S
> 1 2 3
> 4 5 6 7 8 9 10
> 11 12 13 14 15 16 17
> 18 19 20 21 22 23 24
> 25 26 27 28 29 30
>
>
> Thanks for your help.
>


Awk operates on fields if you use $1, $2, etc, not on character columns
of data. Use a tool that works on columns like cut (tail to skip header)

cal 01 2007 | cut -c1-3,19-20 | tail +2

Or if you want to use awk use the substr() function (NR and NF to skip
header and empty lines)

cal 01 2007 | awk 'NR>1 && NF {print substr($0,1,2), substr($0,19,2)}'


Janis

Re: Command to extract saturdays and sundays

am 22.12.2007 23:16:02 von harryooopotter

apogeusistemas@gmail.com wrote...
>
>Hi:
>
>I=B4m looking for a command to show me all saturdays and sundays in a
>specified month. I create this command using awk, but awk change "cal"
>output:
>
># cal 11 2007 | awk '{ print $1,
>$7 }'
>November
>S S
>1
>4 10
>11 17
>18 24
>25

$ cal -m 11 2007 | cut -c15- | tail +2
Sa Su
3 4
10 11
17 18
24 25

Re: Command to extract saturdays and sundays

am 23.12.2007 06:29:56 von tienchi

On Sat, 22 Dec 2007 22:16:02 +0000, Harry331 wrote:

> apogeusistemas@gmail.com wrote...
>>
>>Hi:
>>
>>I=B4m looking for a command to show me all saturdays and sundays in a
>>specified month. I create this command using awk, but awk change "cal"
>>output:
>>
>># cal 11 2007 | awk '{ print $1,
>>$7 }'
>>November
>>S S
>>1
>>4 10
>>11 17
>>18 24
>>25
>
> $ cal -m 11 2007 | cut -c15- | tail +2
> Sa Su
> 3 4
> 10 11
> 17 18
> 24 25

Should it be

$ cal -m 11 2007 | cut -c15- | tail -n+2

cause tail +2 would get a "cannot open file" error.

junmin@thinking ~ $ cal -m 1 2007 | cut -c 15-| tail +2
tail: cannot open `+2' for reading: No such file or directory


???

junmin

--
Posted via a free Usenet account from http://www.teranews.com

Re: Command to extract saturdays and sundays

am 23.12.2007 08:11:11 von Bill Marcum

On 2007-12-23, Junmin H. wrote:
>
>
> Should it be
>
> $ cal -m 11 2007 | cut -c15- | tail -n+2
>
> cause tail +2 would get a "cannot open file" error.
>
> junmin@thinking ~ $ cal -m 1 2007 | cut -c 15-| tail +2
> tail: cannot open `+2' for reading: No such file or directory
>
The -n was not required in older versions of tail and head.

Re: Command to extract saturdays and sundays

am 24.12.2007 11:37:03 von Rakesh Sharma

cal 01 2007 |
sed -e '
/[^0-9 ]/{
/[^a-zA-Z ]/b
}

:pad
s/^.\{1,19\}$/& /
tpad

s/^\(..\).*\(..\)$/\1 \2/
'




On Dec 22, 7:51 pm, apogeusiste...@gmail.com wrote:
> Hi:
>
> I=B4m looking for a command to show me all saturdays and sundays in a
> specified month. I create this command using awk, but awk change "cal"