Hi,
I'm running a script sh, with a date formatted as "YYYYMMDD", as
argument (example : ./my_prog.sh 20111216
In my script, I just would like to test if the user specified an
argument respecting the folowing rules :
- 8 characters long
- constituted only by numbers
I tried to write this :
if [[$1 =~ /^[2][0][1-2][0-9][0-1][0-9][0-3][0-9]$/ ]]
then
.....
fi
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
Stephane CHAZELAS
2011-12-15, 08:43(-08), titof92:
Hi, I'm running a script sh, with a date formatted as "YYYYMMDD", as argument (example : ./my_prog.sh 20111216 In my script, I just would like to test if the user specified an argument respecting the folowing rules : - 8 characters long - constituted only by numbers
I tried to write this : if [[$1 =~ /^[2][0][1-2][0-9][0-1][0-9][0-3][0-9]$/ ]] then ..... fi
[...]
Tu peux parler francais ici, tu sais.
case $1 in (20[12][0-9][01][0-9][0-3][0-9]) ... esac
-- Stephane
2011-12-15, 08:43(-08), titof92:
Hi,
I'm running a script sh, with a date formatted as "YYYYMMDD", as
argument (example : ./my_prog.sh 20111216
In my script, I just would like to test if the user specified an
argument respecting the folowing rules :
- 8 characters long
- constituted only by numbers
I tried to write this :
if [[$1 =~ /^[2][0][1-2][0-9][0-1][0-9][0-3][0-9]$/ ]]
then
.....
fi
[...]
Tu peux parler francais ici, tu sais.
case $1 in
(20[12][0-9][01][0-9][0-3][0-9]) ...
esac
Hi, I'm running a script sh, with a date formatted as "YYYYMMDD", as argument (example : ./my_prog.sh 20111216 In my script, I just would like to test if the user specified an argument respecting the folowing rules : - 8 characters long - constituted only by numbers
I tried to write this : if [[$1 =~ /^[2][0][1-2][0-9][0-1][0-9][0-3][0-9]$/ ]] then ..... fi
[...]
Tu peux parler francais ici, tu sais.
case $1 in (20[12][0-9][01][0-9][0-3][0-9]) ... esac
-- Stephane
titof92
On 15 déc, 18:27, Stephane CHAZELAS wrote:
2011-12-15, 08:43(-08), titof92:> Hi, > I'm running a script sh, with a date formatted as "YYYYMMDD", as > argument (example : ./my_prog.sh 20111216 > In my script, I just would like to test if the user specified an > argument respecting the folowing rules : > - 8 characters long > - constituted only by numbers
> I tried to write this : > if [[$1 =~ /^[2][0][1-2][0-9][0-1][0-9][0-3][0-9]$/ ]] > then > ..... > fi
[...]
Tu peux parler francais ici, tu sais.
case $1 in (20[12][0-9][01][0-9][0-3][0-9]) ... esac
-- Stephane
Super, merci beaucoup. Cela fonctionne bien. Désolé, je pensais poster sur le forum comp.unix.shell... c'est pourquoi mon message était en anglais... ;-)
On 15 déc, 18:27, Stephane CHAZELAS <stephane_chaze...@yahoo.fr>
wrote:
2011-12-15, 08:43(-08), titof92:> Hi,
> I'm running a script sh, with a date formatted as "YYYYMMDD", as
> argument (example : ./my_prog.sh 20111216
> In my script, I just would like to test if the user specified an
> argument respecting the folowing rules :
> - 8 characters long
> - constituted only by numbers
> I tried to write this :
> if [[$1 =~ /^[2][0][1-2][0-9][0-1][0-9][0-3][0-9]$/ ]]
> then
> .....
> fi
[...]
Tu peux parler francais ici, tu sais.
case $1 in
(20[12][0-9][01][0-9][0-3][0-9]) ...
esac
--
Stephane
Super, merci beaucoup. Cela fonctionne bien.
Désolé, je pensais poster sur le forum comp.unix.shell... c'est
pourquoi mon message était en anglais... ;-)
2011-12-15, 08:43(-08), titof92:> Hi, > I'm running a script sh, with a date formatted as "YYYYMMDD", as > argument (example : ./my_prog.sh 20111216 > In my script, I just would like to test if the user specified an > argument respecting the folowing rules : > - 8 characters long > - constituted only by numbers
> I tried to write this : > if [[$1 =~ /^[2][0][1-2][0-9][0-1][0-9][0-3][0-9]$/ ]] > then > ..... > fi
[...]
Tu peux parler francais ici, tu sais.
case $1 in (20[12][0-9][01][0-9][0-3][0-9]) ... esac
-- Stephane
Super, merci beaucoup. Cela fonctionne bien. Désolé, je pensais poster sur le forum comp.unix.shell... c'est pourquoi mon message était en anglais... ;-)