|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
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 . |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
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 . > 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 |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
On 2007-12-23, Junmin H. <tienchi@gmail.com> 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. |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
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´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" |
|
![]() |
| Outils de la discussion | |
|
|