Sponsored Content
Top Forums Shell Programming and Scripting Echo date variable from data input to a script Post 302478169 by iga3725 on Tuesday 7th of December 2010 09:40:16 AM
Old 12-07-2010
Echo date variable from data input to a script

Hi, I'm trying to make a script which you type the year, select the month and day and then create the date in the format 2010-12-7.
Code:
#!/bin/bash

dia () {
echo " Seleccione el dia:"
select file in 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 Salir
do
case $file in
"1") d=1 ; fecha ;;
"2") d=2 ; fecha ;;
"3") d=3 ; fecha ;;
"4") d=4 ; fecha ;;
"5") d=5 ; fecha ;;
"6") d=6 ; fecha ;;
"7") d=7 ; fecha ;;
"8") d=8 ; fecha ;;
"9") d=9 ; fecha ;;
"10") d=10 ; fecha ;;
"11") d=11 ; fecha ;;
"12") d=12 ; fecha ;;
"13") d=13 ; fecha ;;
"14") d=14 ; fecha ;;
"15") d=15 ; fecha ;;
"16") d=16 ; fecha ;;
"17") d=17 ; fecha ;;
"18") d=18 ; fecha ;;
"19") d=19 ; fecha ;;
"20") d=20 ; fecha ;;
"21") d=21 ; fecha ;;
"22") d=22 ; fecha ;;
"23") d=23 ; fecha ;;
"24") d=24 ; fecha ;;
"25") d=25 ; fecha ;;
"26") d=26 ; fecha ;;
"27") d=27 ; fecha ;;
"28") d=28 ; fecha ;;
"29") d=29 ; fecha ;;
"30") d=30 ; fecha ;;
"31") d=31 ; fecha ;;
"Salir") exit 1;;
 *)
    echo "ERROR: Seleccione correctamente... "
    dia;;
esac
done
}

mes () {
echo " Seleccione el mes:"
select file in enero febrero marzo abril mayo junio julio agosto septiembre octubre noviembre diciembre Salir
do
case $file in
"enero") m=1 ; dia ;;
"febrero") m=2 ; dia ;;
"marzo") m=3 ; dia  ;;
"abril") m=4 ; dia  ;;
"mayo") m=5 ; dia  ;;
"junio") m=6 ; dia  ;;
"julio") m=7 ; dia  ;;
"agosto") m=8 ; dia  ;;
"septiembre") m=9 ; dia  ;;
"octubre") m=10 ; dia  ;;
"noviembre") m=11 ; dia  ;;
"diciembre") m=12 ; dia  ;;
"Salir") exit 1;;
 *)
    echo "ERROR: Seleccione correctamente... "
    mes;;
esac
done
}

anno () {
echo " Seleccione la anno, insertando las dos ultimas cifras:"
read yshort

if [[ $( echo $yshort | sed 's/^[-+0-9][0-9]*//' | wc -c ) -ne 1 ]]; then echo "ERROR: Introduzca correctamente dos caracteres numericos." && exit 1; fi

if [[ $( expr length $yshort) -ne 2 ]] ; then echo "ERROR: Introduzca SOLO dos caracteres" && exit 1 ;fi
Y=20$yshort
}

fecha () {
fecha=`echo " $Y-$m-$d"`
echo $fecha
exit 0
}

main () {

anno
mes
dia

}

main

The problem? Simple, I want to select the day regarding the month, I mean, to print 30 days if you selected the month of 30 days and so on.

Any help on how to change my script?
Thanks in advance.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to find files on a given input date

Hello gurus, I need to write a script to find out all the file that got changed on a specific folder since a given input date (Date to be given as Input) Thanx (1 Reply)
Discussion started by: ar.karan
1 Replies

2. Shell Programming and Scripting

Help with Creation of Script to Input Separators in Data

Hi all, I have one problem that is preparing datas so I can run a script to extrat informations for my statistic reports. I receive some datas, that are informations mixed and I need to separate them to analyse. This is an exemple of datas:... (8 Replies)
Discussion started by: Alexis Duarte
8 Replies

3. Shell Programming and Scripting

problem piping input to script with echo

I am trying to have a script run without interaction from the command line. So in my script i have a line like this echo -e "\n\n\ny\ny\n" | ./script the goal being the ability to mimic 3 Enter presses and 2 'y/n' responses with 'y' followed by enter. For some reason tho, it is not... (1 Reply)
Discussion started by: mcdef
1 Replies

4. Shell Programming and Scripting

Need script to take input from file, match on it in file 2 and input data

All, I am trying to figure out a script to run in windows that will allow me to match on First column in file1 to 8th Column in File2 then Insert file1 column2 to file2 column4 then create a new file. File1: 12345 Sam 12346 Bob 12347 Bill File2:... (1 Reply)
Discussion started by: darkoth
1 Replies

5. Shell Programming and Scripting

Script asks to input data

Hi, I have three different files about a warehouse's stock status. Each file shows storage locations, stored product names, quantity of the part and at last column, its price. When there is a change in price, I open those files one by one, search related product name at each row and change... (4 Replies)
Discussion started by: baris35
4 Replies

6. Shell Programming and Scripting

Input date on script

How can I allow users to change the date and time in a script? Say the user1 wil login and he will be inputting the desired date (example format below). I will need this script so the user can login and change the date anytime during the day. I will not allow him to use any command except the date... (2 Replies)
Discussion started by: lhareigh890
2 Replies

7. Shell Programming and Scripting

Script to get previous date for the given input date..

hi all, need a script or command to get the previous date for the given input date... like in my script i will pass date as input parameter like 2014-12-01 and i want the output as previous date.. ie.. 2014-11-30 (2 Replies)
Discussion started by: hemanthsaikumar
2 Replies

8. UNIX for Dummies Questions & Answers

UNIX shells script to echo out the date value

I appreciate if someone answer this question for my learning purpose: Given a filename structure of a COUNTRY CODE, file type, date (YYYYMMDD) and two digit attempt number with an extension of ".dat", write a UNIX shells script to echo out the date value. Example: ... (1 Reply)
Discussion started by: shumail
1 Replies

9. Shell Programming and Scripting

Variable input to awk script

Hi guys, I wrote the following function to compare two csv files column by column. However, sometimes the input needs to be sorted before parsing it to awk. I can do this by changing the awk arguments, but I would like to make this variable if possible. The below doesn't work since the... (3 Replies)
Discussion started by: Subbeh
3 Replies

10. Shell Programming and Scripting

Enhance existing script: Extract Multiple variables & Input in an echo string

Hi Experts I need your help to optimize my script to execute better as I have nearly 1M records & the script is taking close to 40 minutes to execute, so would need support on a faster alternative. Input: file {"house":"1024","zip":"2345","city":"asd","country":"zzv"}... (2 Replies)
Discussion started by: nk1984
2 Replies
DateTime::Locale::es(3) 				User Contributed Perl Documentation				   DateTime::Locale::es(3)

NAME
DateTime::Locale::es SYNOPSIS
use DateTime; my $dt = DateTime->now( locale => 'es' ); print $dt->month_name(); DESCRIPTION
This is the DateTime locale package for Spanish. DATA
This locale inherits from the DateTime::Locale::root locale. It contains the following data. Days Wide (format) lunes martes miercoles jueves viernes sabado domingo Abbreviated (format) lun mar mie jue vie sab dom Narrow (format) L M M J V S D Wide (stand-alone) lunes martes miercoles jueves viernes sabado domingo Abbreviated (stand-alone) lun mar mie jue vie sab dom Narrow (stand-alone) L M M J V S D Months Wide (format) enero febrero marzo abril mayo junio julio agosto septiembre octubre noviembre diciembre Abbreviated (format) ene feb mar abr may jun jul ago sep oct nov dic Narrow (format) E F M A M J J A S O N D Wide (stand-alone) enero febrero marzo abril mayo junio julio agosto septiembre octubre noviembre diciembre Abbreviated (stand-alone) ene feb mar abr may jun jul ago sep oct nov dic Narrow (stand-alone) E F M A M J J A S O N D Quarters Wide (format) 1er trimestre 2X trimestre 3er trimestre 4X trimestre Abbreviated (format) T1 T2 T3 T4 Narrow (format) 1 2 3 4 Wide (stand-alone) 1er trimestre 2X trimestre 3er trimestre 4X trimestre Abbreviated (stand-alone) T1 T2 T3 T4 Narrow (stand-alone) 1 2 3 4 Eras Wide antes de Cristo anno Domini Abbreviated a.C. d.C. Narrow a.C. d.C. Date Formats Full 2008-02-05T18:30:30 = martes 5 de febrero de 2008 1995-12-22T09:05:02 = viernes 22 de diciembre de 1995 -0010-09-15T04:44:23 = sabado 15 de septiembre de -10 Long 2008-02-05T18:30:30 = 5 de febrero de 2008 1995-12-22T09:05:02 = 22 de diciembre de 1995 -0010-09-15T04:44:23 = 15 de septiembre de -10 Medium 2008-02-05T18:30:30 = 05/02/2008 1995-12-22T09:05:02 = 22/12/1995 -0010-09-15T04:44:23 = 15/09/-010 Short 2008-02-05T18:30:30 = 05/02/08 1995-12-22T09:05:02 = 22/12/95 -0010-09-15T04:44:23 = 15/09/-10 Default 2008-02-05T18:30:30 = 05/02/2008 1995-12-22T09:05:02 = 22/12/1995 -0010-09-15T04:44:23 = 15/09/-010 Time Formats Full 2008-02-05T18:30:30 = 18:30:30 UTC 1995-12-22T09:05:02 = 09:05:02 UTC -0010-09-15T04:44:23 = 04:44:23 UTC Long 2008-02-05T18:30:30 = 18:30:30 UTC 1995-12-22T09:05:02 = 09:05:02 UTC -0010-09-15T04:44:23 = 04:44:23 UTC Medium 2008-02-05T18:30:30 = 18:30:30 1995-12-22T09:05:02 = 09:05:02 -0010-09-15T04:44:23 = 04:44:23 Short 2008-02-05T18:30:30 = 18:30 1995-12-22T09:05:02 = 09:05 -0010-09-15T04:44:23 = 04:44 Default 2008-02-05T18:30:30 = 18:30:30 1995-12-22T09:05:02 = 09:05:02 -0010-09-15T04:44:23 = 04:44:23 Datetime Formats Full 2008-02-05T18:30:30 = martes 5 de febrero de 2008 18:30:30 UTC 1995-12-22T09:05:02 = viernes 22 de diciembre de 1995 09:05:02 UTC -0010-09-15T04:44:23 = sabado 15 de septiembre de -10 04:44:23 UTC Long 2008-02-05T18:30:30 = 5 de febrero de 2008 18:30:30 UTC 1995-12-22T09:05:02 = 22 de diciembre de 1995 09:05:02 UTC -0010-09-15T04:44:23 = 15 de septiembre de -10 04:44:23 UTC Medium 2008-02-05T18:30:30 = 05/02/2008 18:30:30 1995-12-22T09:05:02 = 22/12/1995 09:05:02 -0010-09-15T04:44:23 = 15/09/-010 04:44:23 Short 2008-02-05T18:30:30 = 05/02/08 18:30 1995-12-22T09:05:02 = 22/12/95 09:05 -0010-09-15T04:44:23 = 15/09/-10 04:44 Default 2008-02-05T18:30:30 = 05/02/2008 18:30:30 1995-12-22T09:05:02 = 22/12/1995 09:05:02 -0010-09-15T04:44:23 = 15/09/-010 04:44:23 Available Formats d (d) 2008-02-05T18:30:30 = 5 1995-12-22T09:05:02 = 22 -0010-09-15T04:44:23 = 15 EEEd (EEE d) 2008-02-05T18:30:30 = mar 5 1995-12-22T09:05:02 = vie 22 -0010-09-15T04:44:23 = sab 15 HHmm (HH:mm) 2008-02-05T18:30:30 = 18:30 1995-12-22T09:05:02 = 09:05 -0010-09-15T04:44:23 = 04:44 hhmm (hh:mm a) 2008-02-05T18:30:30 = 06:30 p.m. 1995-12-22T09:05:02 = 09:05 a.m. -0010-09-15T04:44:23 = 04:44 a.m. HHmmss (HH:mm:ss) 2008-02-05T18:30:30 = 18:30:30 1995-12-22T09:05:02 = 09:05:02 -0010-09-15T04:44:23 = 04:44:23 hhmmss (hh:mm:ss a) 2008-02-05T18:30:30 = 06:30:30 p.m. 1995-12-22T09:05:02 = 09:05:02 a.m. -0010-09-15T04:44:23 = 04:44:23 a.m. Hm (H:mm) 2008-02-05T18:30:30 = 18:30 1995-12-22T09:05:02 = 9:05 -0010-09-15T04:44:23 = 4:44 hm (h:mm a) 2008-02-05T18:30:30 = 6:30 p.m. 1995-12-22T09:05:02 = 9:05 a.m. -0010-09-15T04:44:23 = 4:44 a.m. Hms (H:mm:ss) 2008-02-05T18:30:30 = 18:30:30 1995-12-22T09:05:02 = 9:05:02 -0010-09-15T04:44:23 = 4:44:23 hms (h:mm:ss a) 2008-02-05T18:30:30 = 6:30:30 p.m. 1995-12-22T09:05:02 = 9:05:02 a.m. -0010-09-15T04:44:23 = 4:44:23 a.m. M (L) 2008-02-05T18:30:30 = 2 1995-12-22T09:05:02 = 12 -0010-09-15T04:44:23 = 9 Md (d/M) 2008-02-05T18:30:30 = 5/2 1995-12-22T09:05:02 = 22/12 -0010-09-15T04:44:23 = 15/9 MEd (E, d-M) 2008-02-05T18:30:30 = mar, 5-2 1995-12-22T09:05:02 = vie, 22-12 -0010-09-15T04:44:23 = sab, 15-9 MMd (d/MM) 2008-02-05T18:30:30 = 5/02 1995-12-22T09:05:02 = 22/12 -0010-09-15T04:44:23 = 15/09 MMdd (MM/dd) 2008-02-05T18:30:30 = 02/05 1995-12-22T09:05:02 = 12/22 -0010-09-15T04:44:23 = 09/15 MMM (LLL) 2008-02-05T18:30:30 = feb 1995-12-22T09:05:02 = dic -0010-09-15T04:44:23 = sep MMMd (d MMM) 2008-02-05T18:30:30 = 5 feb 1995-12-22T09:05:02 = 22 dic -0010-09-15T04:44:23 = 15 sep MMMdd (dd-MMM) 2008-02-05T18:30:30 = 05-feb 1995-12-22T09:05:02 = 22-dic -0010-09-15T04:44:23 = 15-sep MMMEd (E d MMM) 2008-02-05T18:30:30 = mar 5 feb 1995-12-22T09:05:02 = vie 22 dic -0010-09-15T04:44:23 = sab 15 sep MMMMd (d 'de' MMMM) 2008-02-05T18:30:30 = 5 de febrero 1995-12-22T09:05:02 = 22 de diciembre -0010-09-15T04:44:23 = 15 de septiembre MMMMEd (E d MMMM) 2008-02-05T18:30:30 = mar 5 febrero 1995-12-22T09:05:02 = vie 22 diciembre -0010-09-15T04:44:23 = sab 15 septiembre mmss (mm:ss) 2008-02-05T18:30:30 = 30:30 1995-12-22T09:05:02 = 05:02 -0010-09-15T04:44:23 = 44:23 ms (mm:ss) 2008-02-05T18:30:30 = 30:30 1995-12-22T09:05:02 = 05:02 -0010-09-15T04:44:23 = 44:23 y (y) 2008-02-05T18:30:30 = 2008 1995-12-22T09:05:02 = 1995 -0010-09-15T04:44:23 = -10 yM (M/yyyy) 2008-02-05T18:30:30 = 2/2008 1995-12-22T09:05:02 = 12/1995 -0010-09-15T04:44:23 = 9/-010 yMEd (EEE d/M/yyyy) 2008-02-05T18:30:30 = mar 5/2/2008 1995-12-22T09:05:02 = vie 22/12/1995 -0010-09-15T04:44:23 = sab 15/9/-010 yMMM (MMM y) 2008-02-05T18:30:30 = feb 2008 1995-12-22T09:05:02 = dic 1995 -0010-09-15T04:44:23 = sep -10 yMMMEd (EEE, d MMM y) 2008-02-05T18:30:30 = mar, 5 feb 2008 1995-12-22T09:05:02 = vie, 22 dic 1995 -0010-09-15T04:44:23 = sab, 15 sep -10 yMMMM (MMMM 'de' y) 2008-02-05T18:30:30 = febrero de 2008 1995-12-22T09:05:02 = diciembre de 1995 -0010-09-15T04:44:23 = septiembre de -10 yQ (Q yyyy) 2008-02-05T18:30:30 = 1 2008 1995-12-22T09:05:02 = 4 1995 -0010-09-15T04:44:23 = 3 -010 yQQQ (QQQ yyyy) 2008-02-05T18:30:30 = T1 2008 1995-12-22T09:05:02 = T4 1995 -0010-09-15T04:44:23 = T3 -010 yyMM (MM/yy) 2008-02-05T18:30:30 = 02/08 1995-12-22T09:05:02 = 12/95 -0010-09-15T04:44:23 = 09/-10 yyMMM (MMM-yy) 2008-02-05T18:30:30 = feb-08 1995-12-22T09:05:02 = dic-95 -0010-09-15T04:44:23 = sep--10 yyQ (Q yy) 2008-02-05T18:30:30 = 1 08 1995-12-22T09:05:02 = 4 95 -0010-09-15T04:44:23 = 3 -10 yyQQQQ (QQQQ 'de' yy) 2008-02-05T18:30:30 = 1er trimestre de 08 1995-12-22T09:05:02 = 4X trimestre de 95 -0010-09-15T04:44:23 = 3er trimestre de -10 yyyyMM (MM/yyyy) 2008-02-05T18:30:30 = 02/2008 1995-12-22T09:05:02 = 12/1995 -0010-09-15T04:44:23 = 09/-010 Miscellaneous Prefers 24 hour time? Yes Local first day of the week lunes SUPPORT
See DateTime::Locale. AUTHOR
Dave Rolsky <autarch@urth.org> COPYRIGHT
Copyright (c) 2008 David Rolsky. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. This module was generated from data provided by the CLDR project, see the LICENSE.cldr in this distribution for details on the CLDR data's license. perl v5.16.3 2014-06-10 DateTime::Locale::es(3)
All times are GMT -4. The time now is 07:25 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy