I have a log file that's generated on a daily basis, and saved with the Month and day at the end of it. For instance: file_type_Aug17.csv. As part of my excel conversion I need my script to search for the current Month and day(Aug17) and convert it. Thanks for your help!
you mean you wanna convert your file to .csv format??
date "+%m"=Aug
date "+%d"=17
concate them you get Aug17 then search using find command or grep it then convert it..
give it a try.. if not possible we will help you out..
Thanks for your help!
Here's what I have so far.
rm -rf file_file_perf_Aug18.xls
chmod 777 file_file_perf_Aug19.csv
awk -f csc2xls < file_file_perf_Aug19.csv > file_file_perf_Aug19.xls
chmod 777 file_file_perf_Aug19.xls
I have to manually change the number in the date to complete the task. I indicated in the original post the current Month and day. My mistake, not the current day, I need to this script find the day before. Thanks
try changing TZ
echo "$TZ"
if it shows TZ=IST-5:30
change it to TZ=IST-24
then type date you get next date then extract date in whichever way you want and search using that.. for you file..
echo "$TZ" works for me and the result is US/Eastern
Since I'm new to this, in my script what should be my layout.
Here's what I'm trying to accomplish.
I'm trying to automate this as much as possible. These reports are generated the day before. Now in the morning 12AM the next day I need to email an excel formatted report to the heads.
the system generates a csv file that is -rw-r--r--, I normally have to chmod to perform execute.
How would I implemented the date portion into my script to pull or parse the correct file with the naming convention I provided?
CURRENT_DATE=`date +%Y%m%d`
echo "$CURRENT_DATE"
OLD1=`date +%d`
OLD2=`expr $OLD1 - 1`
OLD_ONE=`date +%Y%m`$OLD2
echo"$OLD_DATE"
See if this helps you to get previous date.
- nilesh
Thanks!
This portion of the script is displaying
bash-3.00$ CURRENT_DATE='date + %Y%m%d'
bash-3.00$ echo "$CURRENT_DATE"
this output
date + %Y%m%d
bash-3.00$ CURRENT_DATE='date + %Y%m%d' don't use ' use `
Nothing is being displayed
$ CURRENT_DATE=`date + %Y%m%d`
$ echo "$CURRENT_DATE"
$
Thanks!
oh ho..
use this....
Excellent it works!
I've modified the whole script, but I'm not getting the final result.
bash-3.00$ CURRENT_DATE=`date "+%Y%m%d"`
bash-3.00$ echo "$CURRENT_DATE"
20080822
bash-3.00$ OLD1=`date "+%d"`
bash-3.00$ OLD2=`expr $OLD1 - 1`
bash-3.00$ OLD_ONE=`date "+%Y%m"`$OLD2
bash-3.00$ echo"$OLD_DATE"
bash-3.00$
Is possible to ouput the shortname version of the month? Like Jan, Feb, Aug.
Thanks!
echo `date +"%b"`
I've tried the code below, but I not getting anything. Please help!
CURRENT_DATE=`date "+%m%d%Y"`
echo "$CURRENT_DATE"
OLD1=`date "+%d"`
OLD2=`expr $OLD1 - 1`
OLD_ONE=`date "+%Y%d"`
echo"$OLD_ONE"
rm -rf *.xls
chmod 777 file_file_file_OLD_ONE.csv
awk -f csc2xls < file_file_file__OLD_ONE.csv > file_file_file_OLD_ONE.xls
chmod 777 file_file_file_OLD_ONE.xls
Problem solved! Thanks for all your help!
How would I export the excel version into a Windows env for further processing?
CURRENT_DATE=`date "+%b%d"`
echo "$CURRENT_DATE"
OLD1=`date "+%b"`
OLD2=`expr "$OLD1 - 1"`
OLD_ONE=`date "+%b%Y"`$OLD2
echo"$OLD_DATE"
CURRENT_DATE=`date "+%b%d%Y"`
echo "$CURRENT_DATE"
OLD1=`date "+%d"`
OLD2=`expr $OLD1 - 1`
OLD_ONE=`date "+%b"`$OLD2
echo "$OLD_ONE"
rm -rf *.xls
chmod 777 file_file_perf_$OLD_ONE.csv
awk -f csc2xls < file_file_perf_$OLD_ONE.csv > file_file_perf_$OLD_ONE.xls
chmod 777 file_file_perf_$OLD_ONE.xls
This script works fine now, but I need to modify to also accept inputs. It works fine to give me the day before info. But when I'm away more than a day, I can't get the day before lets say for two days back. I think it would be best to have an if statement to allow the input month and day, once I log into the system and it's more than two days past.
For instance 8/28 I ran the report I got the info for 8/28, but then I came back on 9/2 I'm only getting info for 9/1. I need to be able to qualify the day, or something of that nature, please help!