Sponsored Content
Top Forums Shell Programming and Scripting Displaying current date time of EDT in IST time Post 302781371 by Don Cragun on Saturday 16th of March 2013 10:17:20 AM
Old 03-16-2013
Quote:
Originally Posted by chidori
wow..!! , i did not know that shell has the ability to treat first one as variable assignment and next one it expands into a command. Thats a new thing i learnt today. Thank you
Both are variable assignments, but since they are at the beginning of a command (not complete commands on their own), the settings only affect affect the environment of the command being run. They do not affect the current shell execution environment. For example:
Code:
$ TZ=PST8PDT
$ date;TZ=IST-5:30 date;date
Sat Mar 16 07:13:53 PDT 2013
Sat Mar 16 19:43:53 IST 2013
Sat Mar 16 07:13:53 PDT 2013
$ echo $TZ
PST8PDT
$

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

param as current date+time

Hi All, I need to pass param on aix "errpt -a -s MMDDHHMMYY -e MMDDHHMMYY". How do I read the date+time on the system and pass it as parameter? I need also the -s as previous day and the -e as current day. Thanks, itik (1 Reply)
Discussion started by: itik
1 Replies

2. Shell Programming and Scripting

Get date and time for past 1 hour from current date

Hi, I need to get the date and time for past 1 hour from the current date. Anyone know how to do so? Thanks (5 Replies)
Discussion started by: spch2o
5 Replies

3. Shell Programming and Scripting

problem with displaying date and adding time

Hi, I have a log file with contents like 81.49.74.131 - - 81.49.74.131 - - 116.112.52.31 - - 116.112.52.31 - - I need an output like this 81.49.74.131 14/Sep/2008 Time duration: 00:06:00 116.112.52.31 15/Sep/2008 Time duration: 00:00:01 Please anyone suggest a script for this.... (1 Reply)
Discussion started by: FuncMx
1 Replies

4. Solaris

changing time zone from ist to bst

Hi, Can anybody tell me how to change time zone from ist to bst, What changes should be done in /etc/TIMEZONE file. wheather it is possible to change timezone without rebooting the server. Regards Manoj (1 Reply)
Discussion started by: manoj.solaris
1 Replies

5. Shell Programming and Scripting

Prefix the current date and time to the output of ps

Hi, I need to write a script, that will take the current date, time, and the output from # ps -eo pid,tid,class,rtprio,ni,pri,psr,pcpu,stat,wchan:14,comm and spit it to a file, so it'll look like this... PID TID CLS RTPRIO NI PRI PSR %CPU STAT WCHAN COMMAND 1 1 TS... (2 Replies)
Discussion started by: Bloke
2 Replies

6. Shell Programming and Scripting

How far is given date from current time?

give a date and time: Jun 12 21:05:16 06-12-2012 21:05:16 2012/06/12 21:05:16 How can i subtract these dates and times from the current date and time and get back the difference in seconds? a one liner like: echo "Jun 12 21:05:16" | some perl/awk programming 90900s (2 Replies)
Discussion started by: SkySmart
2 Replies

7. UNIX for Dummies Questions & Answers

Adding hours and minutes to current date (Only to date not to time)

Hi, I want to add some hours and minutes to the current date. For example, if the current date is "July 16, 2012 15:20", i want to add 5 hours 30 minutes to "July 16, 2012 00:00" not to "July 16, 2012 15:20". Please help. Thanks! (4 Replies)
Discussion started by: manojgarg
4 Replies

8. Shell Programming and Scripting

Add current date and time

i have file 1.txt asdas|csada|13|03|10|04|23|A1|canberra sdasd|sfdsf|13|04|26|23|28|A1|sydney i want to add today's date and time in the end of each row expected output asdas|csada|13|03|10|04|23|A1|canberra|130430|1358 sdasd|sfdsf|13|04|26|23|28|A1|sydney|130430|1358 todays date... (10 Replies)
Discussion started by: radius
10 Replies

9. Shell Programming and Scripting

Need to substract date with current date and time

I have below file which contain the date in column 3,4,5 12345 open 10/10/13 10:08 PM 3 application is in java 67899 open 12/10/13 2:31 AM 2 apps can be reach 23456 open 11/9/13 2:31 AM 4 java is OK 65432 open 12/10/13 10:07 PM 9 we are... (1 Reply)
Discussion started by: vijay_rajni
1 Replies

10. UNIX for Beginners Questions & Answers

Getting the current time from a website and parsing date

I am trying to work on a script to grab the UTC time from a website So far I was able to cobble this together. curl -s --head web-url | grep ^Date: | sed 's/Date: //g' Which gives me the result I need. Wed, 06 Dec 2017 21:43:50 GMT What I need to is extract the 21:43:50 and convert... (4 Replies)
Discussion started by: allisterB
4 Replies
exec(1) 							   User Commands							   exec(1)

NAME
exec, eval, source - shell built-in functions to execute other commands SYNOPSIS
sh exec [argument]... eval [argument]... csh exec command eval argument... source [-h] name ksh *exec [argument]... *eval [argument]... ksh93 +exec [-c] [-a name] [command [argument ... ]] +eval [argument]... DESCRIPTION
sh The exec command specified by the arguments is executed in place of this shell without creating a new process. Input/output arguments and appear and, if no other arguments are specified, cause the shell input/output to be modified. The arguments to the eval built-in are read as input to the shell and the resulting command(s) executed. csh exec executes command in place of the current shell, which terminates. eval reads its arguments as input to the shell and executes the resulting command(s). This is usually used to execute commands generated as the result of command or variable substitution. source reads commands from name. source commands can be nested, but if they are nested too deeply the shell can run out of file descrip- tors. An error in a sourced file at any level terminates all nested source commands. -h Place commands from the file name on the history list without executing them. ksh With the exec built-in, if arg is specified, the command specified by the arguments is executed in place of this shell without creating a new process. Input/output arguments can appear and affect the current process. If no arguments are specified the effect of this command is to modify file descriptors as prescribed by the input/output redirection list. In this case, any file descriptor numbers greater than 2 that are opened with this mechanism are closed when invoking another program. The arguments to eval are read as input to the shell and the resulting command(s) executed. On this man page, ksh(1) commands that are preceded by one or two * (asterisks) are treated specially in the following ways: 1. Variable assignment lists preceding the command remain in effect when the command completes. 2. I/O redirections are processed after variable assignments. 3. Errors cause a script that contains them to abort. 4. Words, following a command preceded by ** that are in the format of a variable assignment, are expanded with the same rules as a variable assignment. This means that tilde substitution is performed after the = sign and word splitting and file name genera- tion are not performed. ksh93 exec is a special built-in command that can be used to manipulate file descriptors or to replace the current shell with a new command. If command is specified, then the current shell process is replaced by command rather than running command and waiting for it to complete. There is no need to use exec to enhance performance since the shell implicitly uses the exec mechanism internally whenever possible. If no operands are specified, exec can be used to open or close files, or to manipulate file descriptors from 0 to 9 in the current shell environment using the standard redirection mechanism available with all commands. The close-on-exec flags is set on file descriptor numbers greater than 2 that are opened this way so that they are closed when another program is invoked. Because exec is a special command, any failure causes the script that invokes it to exit. This can be prevented by invoking exec from the command utility. exec cannot be invoked from a restricted shell to create files or to open a file for writing or appending. eval is a shell special built-in command that constructs a command by concatenating the arguments together, separating each with a space. The resulting string is taken as input to the shell and evaluated in the current environment. command words are expanded twice, once to construct argument, and again when the shell executes the constructed command. It is not an error if argument is not specified. On this manual page, ksh93 commands that are preceded by one or two + symbols are special built-in commands and are treated specially in the following ways: 1. Variable assignment lists preceding the command remain in effect when the command completes. 2. I/O redirections are processed after variable assignments. 3. Errors cause a script that contains them to abort. 4. They are not valid function names. 5. Words following a command preceded by ++ that are in the format of a variable assignment are expanded with the same rules as a variable assignment. This means that tilde substitution is performed after the = sign and field splitting and file name genera- tion are not performed. OPTIONS
ksh93 The following options are supported by ksh93 exec: -a name argv[0] is set to name for command. -c Clear all environment variables before executions except variable assignments that are part of the current exec command. EXIT STATUS
ksh The following exit values are returned by exec: 0 Successful completion. 1-125 A redirection error occurred. 127 command was not found. 126 command was found, but it is not an executable utility. ksh93 The following exit values are returned by exec. If command is specified, exec does not return. 0 Successful completion. All I/O redirections were successful. >0 An error occurred. The following exit values are returned by eval: If argument is not specified, the exit status is 0. Otherwise, it is the exit status of the command defined by the argument operands. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
csh(1), ksh(1), ksh93(1), sh(1), attributes(5) SunOS 5.11 8 Apr 2008 exec(1)
All times are GMT -4. The time now is 12:24 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy