datum in variable
ItsCooL
- perl
hi
ich weiss das das hier kein shell forum ist, aber ich weiss nicht mehr weiter;
wie kann ich in einerm shell script das aktuelle datum in einer variable ablegen?
mit #!/bin/sh
datum=$(date +%Y%d%m);
funzt es net -> error: `datum=$' unexpected
kann mir einer helfen ??
cya
Its My Life And Its CooL
Hallo,
Diese Routine liest das Datum aus, formatiert es und speichert es in der Variablen $date
Schneid raus, was Du brauchst und wirf den Rest weg ;-)
Stammt ursprünglich aus dem Formmail Skript von Matt Wright.
Gruß,
Tobias
sub get_date {
# Define arrays for the day of the week and month of the year. #
@days = ('Sunday','Monday','Tuesday','Wednesday',
'Thursday','Friday','Saturday');
@months = ('January','February','March','April','May','June','July',
'August','September','October','November','December');
# Get the current time and format the hour, minutes and seconds. Add #
# 1900 to the year to get the full 4 digit year. #
($sec,$min,$hour,$mday,$mon,$year,$wday) = (localtime(time))[0,1,2,3,4,5,6];
$time = sprintf("%02d:%02d:%02d",$hour,$min,$sec);
$year += 1900;
# Format the date. #
$date = "$days[$wday], $months[$mon] $mday, $year at $time";
}
THX
cya
Its My Life And Its CooL
Hallo,
Diese Routine liest das Datum aus, formatiert es und speichert es in der Variablen $date
Schneid raus, was Du brauchst und wirf den Rest weg ;-)
Stammt ursprünglich aus dem Formmail Skript von Matt Wright.
Gruß,
Tobias
sub get_date {
# Define arrays for the day of the week and month of the year. #
@days = ('Sunday','Monday','Tuesday','Wednesday',
'Thursday','Friday','Saturday');
@months = ('January','February','March','April','May','June','July',
'August','September','October','November','December');
# Get the current time and format the hour, minutes and seconds. Add #
# 1900 to the year to get the full 4 digit year. #
($sec,$min,$hour,$mday,$mon,$year,$wday) = (localtime(time))[0,1,2,3,4,5,6];
$time = sprintf("%02d:%02d:%02d",$hour,$min,$sec);
$year += 1900;
# Format the date. #
$date = "$days[$wday], $months[$mon] $mday, $year at $time";
}