The UNIX and Linux Forums  

Go Back   UNIX e Linux Forum > Inizio Forum > Shell scripting e di programmazione
.
google unix.com



Shell scripting e di programmazione Pubblica domande su KSH, CSH, SH, Bash, Perl, PHP, sed, awk e da altri script di shell e linguaggi di scripting shell qui.

Più di UNIX e Linux Forum Argomenti potreste trovare utili
Filo Thread Starter Forum Risposte Ultimo Post
Usa data comando per trovare il mese scorso Cbish68 Shell scripting e di programmazione 5 08-10-2007 11:32 AM
scoprire mesi a partire da una data rudoraj UNIX for Dummies Domande & Risposte 5 07-03-2007 09:21 AM
Come trovare il primo giorno del mese precedente in UNIX? Mohapatra Shell scripting e di programmazione 10 07-02-2007 09:57 PM
Hai bisogno di aiuto, ogni venerdì in un mese LAICI Shell scripting e di programmazione 3 12-09-2006 09:12 AM
Trova tutti i file da mesi Maldini Shell scripting e di programmazione 13 08-03-2005 02:22 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Cerca in questo Thread Rate Thread Modalità di visualizzazione
  #1 (permalink)  
Old 05-30-2007
leslie02 leslie02 is offline
Utente Registrato
  
 

Join Date: May 2007
Interventi: 5
Smile Come faccio a trovare il terzo venerdì di ogni mese?

Aiuto per favore! Ho bisogno di leggere il calendario e inserire la data del terzo Venerdì di ogni mese, in una variabile per il confronto in un "if". Come farlo?

Thnx,
leslie02
  #2 (permalink)  
Old 05-30-2007
aigles's Avatar
Aigles aigles is offline Forum Advisor  
Utente Registrato
  
 

Iscriviti Data: aprile 2004
Località: Bordeaux, Francia
Messaggi: 1.433
Il terzo venerdì è sempre tra i giorni 15 e 21 compreso del mese.
Puoi fatto la prova così:

Codice:
day_of_week=$(date +%w)  # (0..6); 0 is Sunday, 5 is Friday
day_of_month=$(date +%e) # space padded
if [ ${day_of_week} -eq 5 -a ${day_of_month} -ge 15 -a ${day_of_month} -le 21 ]
then
   echo "third Friday "
fi

Jean-Pierre.
  #3 (permalink)  
Old 05-30-2007
Shell_Life's Avatar
Shell_Life Shell_Life is offline
Utente Registrato
  
 

Iscriviti Data: marzo 2007
Localizzazione: Bahia, Brasile
Interventi: 695
Leslie,
Vedi se questo funziona per voi:

Codice:
typeset -i mMth=1
mYear='2007'
while [ ${mMth} -le 12 ]
do
  m3Friday=`cal ${mMth} ${mYear} | tail +3 | cut -c16,17 | sed '/^ *$/d' | sed -n '3p'`
  echo "Third Friday of "${mMth}"/"${mYear}" = "${m3Friday}
  mMth=${mMth}+1
done

  #4 (permalink)  
Old 05-31-2007
akrathi akrathi is offline
Utente Registrato
  
 

Join Date: Sep 2005
Interventi: 41
Questo dovrebbe funzionare

Grazie
Ashok

cal 07 2007 | cut-C16-18 | tail -4 | head -1
  #5 (permalink)  
Old 05-31-2007
anbu23 anbu23 is offline Forum Advisor  
Utente Registrato
  
 

Iscriviti Data: marzo 2006
Località: Bangalore, India
Messaggi: 1.398

Codice:
cal 05 2007 | sed -n "5{s/ *[0-9]\{2\}$//;s/^.* //p;}"

  #6 (permalink)  
Old 05-31-2007
aigles's Avatar
Aigles aigles is offline Forum Advisor  
Utente Registrato
  
 

Iscriviti Data: aprile 2004
Località: Bordeaux, Francia
Messaggi: 1.433
Shell_Life, akrathi, anbu23, sembra che il vostro soluzioni non funzionano in tutti i casi di:

Codice:
$ cal 12 2007
       December 2007      
Sun Mon Tue Wed Thu Fri Sat  
                         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  31

$ cal 12 2007 | tail +3 | cut -c16,17 | sed '/^ *$/d' | sed -n '3p'
 2
$ cal 12 2007 | cut -c16-18 | tail -4 | head -1
 13
$ cal 12 2007 | sed -n "5{s/ *[0-9]\{2\}$//;s/^.* //p;}"
14
$

Una possibile soluzione:

Codice:
$ cal 12 2007 | awk 'NR>2 && NF>=2 && ++w==3 {print $6}'
21
$ cal 07 2007 | awk 'NR>2 && NF>=2 && ++w==3 {print $6}'
20
$ cal 6 02007 | awk 'NR>2 && NF>=2 && ++w==3 {print $6}' 
15
$

Jean-Pierre.
  #7 (permalink)  
Old 05-31-2007
ghostdog74 ghostdog74 is offline Forum Advisor  
Utente Registrato
  
 

Join Date: Sep 2006
Interventi: 2.557
questo non fa uso di cal

Codice:
count=0
month="05"
for s in `seq 1 31`
do
 fr=$(date +%a --date="2007-$month-$s" )
 if [ "$fr" == "Fri" ];then
     friday[$count]=$s
     count=$((count+1))
 fi 
done
echo ${friday[2]} #third fri

Closed Thread

Segnalibri

Thread Tools Cerca in questo Thread
Cerca in questo Thread:

Ricerca Avanzata
Modalità di visualizzazione Vota questo thread
Vota questo thread:

Distacco regolamento
Tu non può post nuovo thread
Tu non può inviare una risposta
Tu non può postare allegati
Tu non può modificare i tuoi post

BB codice è Su
Smilies sono Su
[IMG] codice Su
Codice HTML è Chiuso
Trackbacks sono Su
Pingbacks sono Su
Refbacks sono Su




Tutti gli orari sono GMT -4. La data di oggi è 06:47 PM.


Powered by: vBulletin, Copyright © 2000 - 2006, Jelsoft Enterprises Limited. Traduzioni Powered by .
vBCredits v1.4 Copyright © 2007 - 2008, PixelFX Studios
UNIX e Linux Forum Content Copyright © 1993-2009. Tutti i diritti Reserved.Ad di gestione da RedTyger

Contenuti pertinenti URL da vBSEO 3.2.0