PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > comp.unix.shell > Command to extract saturdays and sundays
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.unix.shell Using and programming the Unix shell.

Command to extract saturdays and sundays

Réponse
 
LinkBack Outils de la discussion
Vieux 22/12/2007, 14h51   #1
apogeusistemas@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Command to extract saturdays and sundays

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 .

  Réponse avec citation
Vieux 22/12/2007, 15h01   #2
Janis Papanagnou
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Command to extract saturdays and sundays

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
  Réponse avec citation
Vieux 22/12/2007, 22h16   #3
Harry331
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Command to extract saturdays and sundays

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

  Réponse avec citation
Vieux 23/12/2007, 05h29   #4
Junmin H.
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Command to extract saturdays and sundays

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

  Réponse avec citation
Vieux 23/12/2007, 07h11   #5
Bill Marcum
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Command to extract saturdays and sundays

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.
  Réponse avec citation
Vieux 24/12/2007, 10h37   #6
Rakesh Sharma
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Command to extract saturdays and sundays


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"

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 13h31.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,11972 seconds with 14 queries