Sponsored Content
Top Forums Shell Programming and Scripting variable part of variable name Post 302161667 by Smoker on Friday 25th of January 2008 10:31:20 AM
Old 01-25-2008
variable part of variable name

Greetings

I am having a hard time trying to figure out how to use a variable as part of another variables name.

For instance:

A="PRE"
eval ${A}_DAY=`date +%d`
echo ${A}_DAY
echo $PRE_DAY

output:
PRE_DAY
25

I would appreciate some help with this.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

ksh: A part of variable A's name is inside of variable B, how to update A?

This is what I tried: vara=${varb}_count (( vara += 1 )) Thanks for help (4 Replies)
Discussion started by: pa3be
4 Replies

2. Shell Programming and Scripting

Repacing part of string with a variable

I have following strings in a file DUPTASMTRMMBAL,20070416200704160117232101172321,,,,,,,@@@Y DUPTASMTRMMCON,20070416200704160127189901271899,,,,,,,@@@Y DUPTASMTRMMHG,,20070416200704160112051001120510,,,,,,,@@@Y What i need to do is replace the date 20070416 with anoth date which is stored in... (4 Replies)
Discussion started by: divz
4 Replies

3. Shell Programming and Scripting

direction symbol in a variable as part of the command

Hi, How can I get this to work? #!/bin/ksh if ; then direction=">>" else direction=">" fi cat some_file_name $direction temp.txt exit This shell script is not happy with using "$direction" opposed to ">" or ">>". Thanks. (5 Replies)
Discussion started by: peterloo
5 Replies

4. Shell Programming and Scripting

Copy part of a variable

Hi, i was using a input file to get the last line of the file.But now i have stored the values from the file to a variable and want the last line from the variable . Slightly confused on how to extract that data from the variable. previous code, cat input.txt <TIME>00:15:48</TIME>... (2 Replies)
Discussion started by: Shellslave
2 Replies

5. Shell Programming and Scripting

Variable of Content From Part of Other File

I may not being doing this description justice, but I'll give it a try. I created a mailx script; there will be several messages using the same script where the only difference is the content. So I figured I'd make the content of the message a variable retrieved from a separate file. I have five... (5 Replies)
Discussion started by: royarellano
5 Replies

6. Shell Programming and Scripting

How read the part of the string into a variable?

Hi, I'm using bash and brand new to shell script. I would like to do the following. I have a string which is "UPDATE=1.0". I would like to read the value "1.0" alone in a variable. i.e the things afer "=" How do I do that? Thanks, (1 Reply)
Discussion started by: scriptfriend
1 Replies

7. UNIX for Dummies Questions & Answers

Removing Part of a variable based on a pattern

Hi All, I am writing a script to work with files in a folder. The files are all in the following patterns (without quotes): "some filename - NxNN - the end.YYY" or "some filename - NNxNN - the end.YYY" Where N = a single number and YYY is the extension. Basically what I want... (5 Replies)
Discussion started by: sgtbobie
5 Replies

8. Shell Programming and Scripting

Using the part of a line as a variable?

Hello Friends, I need a command (or script line) that allows me to use of a part of line (given by me) as a variable. Let us assume the name of the command is MYCMD. When I type MYCMD fish://mfong@vhl.gov.nd/homefolder/hhk/ADS/ it must do the following job cd /homefolder/hhk/ADS/ ... (18 Replies)
Discussion started by: rpf
18 Replies

9. Shell Programming and Scripting

use some part of variable value to replace ../../ values in a file

hi, i have variable value as follows val="/dir1/dir2/dir3/dir4/dir5/dir6/file1" it is pointing to some file location. and i have another file as ../../dir4/file3 ../../dir4/dir5/file4 ../../dir7/file5 i want the output as /dir1/dir2/dir3/dir4/file3 (7 Replies)
Discussion started by: snreddy_gopu
7 Replies

10. Programming

PASSING PART OF FILE CONTENT TO VARIABLE

All, I have a log file containing lots of data now i want to extract all text between block below(names) without the title or end pattern but only names, ++++START++++ SCOTT TIGER HENRY PAUL JARED OTIENO OMOLLO JA NIGERIA ++++END++++ the names i want to return and store in a variable in... (1 Reply)
Discussion started by: Scott2000
1 Replies
DATETIME.SETTIMESTAMP(3)						 1						  DATETIME.SETTIMESTAMP(3)

DateTime::setTimestamp - Sets the date and time based on an Unix timestamp

       Object oriented style

SYNOPSIS
public DateTime DateTime::setTimestamp (int $unixtimestamp) DESCRIPTION
Procedural style DateTime date_timestamp_set (DateTime $object, int $unixtimestamp) Sets the date and time based on an Unix timestamp. PARAMETERS
o $object -Procedural style only: A DateTime object returned by date_create(3). The function modifies this object. o $unixtimestamp - Unix timestamp representing the date. RETURN VALUES
Returns the DateTime object for method chaining or FALSE on failure. EXAMPLES
Example #1 DateTime.setTimestamp(3) example Object oriented style <?php $date = new DateTime(); echo $date->format('U = Y-m-d H:i:s') . " "; $date->setTimestamp(1171502725); echo $date->format('U = Y-m-d H:i:s') . " "; ?> Procedural style <?php $date = date_create(); echo date_format($date, 'U = Y-m-d H:i:s') . " "; date_timestamp_set($date, 1171502725); echo date_format($date, 'U = Y-m-d H:i:s') . " "; ?> The above examples will output something similar to: 1272508903 = 2010-04-28 22:41:43 1171502725 = 2007-02-14 20:25:25 NOTES
Using the Unix timestamp format to construct a new DateTime object is an alternative when using PHP 5.2, as shown in the example below. Example #2 DateTime.setTimestamp(3) alternative in PHP 5.2 <?php $ts = 1171502725; $date = new DateTime("@$ts"); echo $date->format('U = Y-m-d H:i:s') . " "; ?> The above example will output something similar to: 1171502725 = 2007-02-14 20:25:25 SEE ALSO
DateTime.getTimestamp(3). PHP Documentation Group DATETIME.SETTIMESTAMP(3)
All times are GMT -4. The time now is 12:56 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy