![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to use datecalc for adding hours | ucbus | UNIX for Dummies Questions & Answers | 5 | 06-03-2008 01:48 PM |
| datecalc question. | trey85stang | Shell Programming and Scripting | 4 | 05-08-2008 06:20 PM |
| datecalc | tostay2003 | Shell Programming and Scripting | 1 | 08-21-2007 07:20 AM |
| Help on runing a script | mig28mx | UNIX for Dummies Questions & Answers | 1 | 01-06-2006 02:24 PM |
| runing a script as superuser | bcheaib | UNIX for Dummies Questions & Answers | 2 | 07-06-2004 10:24 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
i have a script in bourne called cdrsnokia.sh and inside of it calls a script called resta_dias where it calls the datecalc script (perderabos date calculator).
The purpose is to rest (-) one day arithmetical operation the content of each line and the result is passed to another file lista2;after that, i have to make a report how many lines there are per line ie: day number 01 4 02 2 lista1 has this structure: lista1 02/01/2007 02/01/2007 02/01/2007 02/01/2007 03/01/2007 04/01/2007 04/01/2007 05/01/2007 05/01/2007 output should be: lista2 01/01/2007 01/01/2007 01/01/2007 0/01/2007 02/01/2007 03/01/2007 03/01/2007 04/01/2007 04/01/2007 The real problem is that the script generates the file lista2, in base of this file i couild use grep to count the lines per day, but the the lines in lista2 are in blank. $more lista2 // // // // // // // // As you can see above ths script datecalc is runnind but the values of the fields are in blank. I was using a former script qith awk, it was working but its too sloowly. I would apreciate hugly your help. my work experience is in bourne but no korn shell. Here i attach the scripts. (i dont attach the datecalc perderabos calculator) cdrsnokia.sh ajusta_fecha() { cut -f1 -d " " listacdrs|sort -t/ -k2 > lista1 valida=`cut -f2 -d "/" lista1|uniq|grep -v $mes lista1|uniq` if [ $? -eq 0 ] then resta_dias else } resta_dias #!/bin/ksh #typeset -Z2 month2 day2 while IFS="/" read day month year; do set +A a $(datecalc -a $year $month $day -1) day2=${a[2]} month2=${a[1]} echo ${day2}/${month2}/${a[0]} done < lista1 > lista2 exit 0 |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
This line is wrong:
set +A a $(datecalc -a $year $month $day -1) You need a space between the minus sign and the 1... like this: set +A a $(datecalc -a $year $month $day - 1) |
||||
| Google The UNIX and Linux Forums |