Hi,
I am using shell (#!/bin/bash), i am trying to set my date in a script date.sh, i want this dates to be used by another scripts.
I have tried to make:
#!/bin/bash
begin_date =`date +%Y_%m_%d_%H_%M_%S`,
i also tried:
#!/bin/bash
begin_date =20080709 12:14:11, then i write in other script the date as ($begin_date), but it always gives me begin_date : command not found!
I would like to write the date as numbers like date = 20080721 12:14:11 and then the other script should read it.
I think it should be simple, please can you help me how i can assign this date and time and how i should call it from my other scripts?
i want to change the date from script to script, so i am tryingto make this script to change the date manually, from today to next month etc... i would like to set like 3 variables for example:
begin_date1 = 2008-07-07_11:12:12 (sysdate)
begin_date2 = 2008_08-08 14:13:34 (next month)
etc ...
Last edited by rosalinda; 07-07-2008 at 07:38 AM..
How are you calling the date.sh script from the other scripts? Can you please post that. I tried the following and it worked:
The following is the date.sh script. Please note that there is no export command in this:
The following is prog1.sh where I want to use the begin_date variable. I have sourced the date.sh script in the prog1.sh script:
Now when I execute prog1.sh as follows:
Just for clarification, the leading "." in line no 3 in prog1.sh is for sourcing a script within another script, and the ./date.sh is to specify that the date.sh is in the current directory (the same directory where the prog1.sh is located), if you have placed the date.sh in some other location such as /home/user01/comm_scripts, you can replace the ./ with the full path of the script.
Hi,
Thank you very much for your kind explanation. it works now.
but can you tell me how i can decide my own date, if i decide a date and time different than sysdate it gives me command not found. i would like to precise my own special dates and time like next month 2008-08-09 00:00:02 etc.
i am trying like this, but doesn't work: #!/bin/sh
begin_date=`2008_08_09_11_12_14 +%Y_%m_%d_%H_%M_%S`
The back ticks (also known as grave-accent) you are using means that the contents are to be executed and their result placed in its place, so the lines:
or
are incorrect as 2008_08_09_11_12_14 +%Y_%m_%d_%H_%M_%S is not a command in unix and neither is 2008_08_09_11_12_14.
If you want to specify your own date then you can do that as follows:
Hi,
If I change date and time in global zone, then it will affect in non global zones.
During this process what files will get affect in non global zones and which mechanism it's using to change.
gloabl zone:Solaris 11.3 X86
TIA (1 Reply)
hi all,
Just a simple question but i cant get the answers in the book -
In my globalzone , assuming i have 4 cpus (psrinfo -pv = 0-3), if i set dedicated-cpu (ncpus=2) for my local zone
Is my globalzone left with 2 cpus or still 4 cpus ? Does localzone "resource reservation.e.g. cpu in... (6 Replies)
Hi,
I have a file which has a date extension to it.
Like <filename>_01012014.
I need to rename the file as 12152013 , that is i need to be able to subtract 15 days from the date of the file name.
Please advise how this can be handled using shell scripting.
Regards,
VN (8 Replies)
Hi,
Have assigned values in Array and iterating in while loop and would require values outside of the loop. But its returning NULL.
could you please help us how to define Global array declaration in Unix shell scripting?
i am using Kron shell.
Thanks in advance. (2 Replies)
Hello,
I need to create a shell script that appends a filename to create a name with the date and time appended that is guaranteed to not exist. That is, the script insures you will not overwrite a file with the same name. I am lost with this one. I know I need to use date but after that I am... (3 Replies)
I am looking to do something where if I created a file named backup,or whatever it would print a name like “backup_Apr_11_2011”. Thanks citizencro (1 Reply)
Hello,
I am trying to show today's date and time in a better format than ‘date' (Using positional parameters). I found a command mktime and am wondering if this is the best command to use or will this also show me the time elapse since 1/30/70? Any help would be greatly appreciated, Thanks... (3 Replies)
Hi Guys,
My requirement is I have file called /opt/orahome/.profile in non global zone.
PATH=/usr/bin:/usr/ucb:/etc:/usr/sbin:/usr/local/bin:/usr/openwin/bin:.
export PATH
PS1="\${ORACLE_SID}:`hostname`:\$PWD$ "
export PS1
EDITOR=vi
export EDITOR
ENV=/opt/orahome/.kshrc
export ENV... (1 Reply)
Hiee .... i want an immediate solution for this....
Let replace.cfg file contains a list of files to be replaced the old dates with new dates......
The script must take 3 parameters....
1) old date
2) new date
3) .config file
Can u get me the solution......
I tried with sed but i... (2 Replies)
Can I determine when the particular file was created, in korn-shell. Can please someone help me. If possible please mail the solution to me.
my mail id: bharat.surana@gmail.com (1 Reply)