Sponsored Content
Top Forums Shell Programming and Scripting Assigning a value to a variable Post 302862495 by erin00 on Thursday 10th of October 2013 10:32:03 PM
Old 10-10-2013
Assigning a value to a variable

Hi

I have a script that accepts an input date in YYYY-MM-DD format.

After that, I used sed to delete the hyphen (-) which gives me an output YYYY MM DD.

My question is, how can I assign those three numbers to a three different variable.

Example:

2013-11-23 will become 2013 11 23

I want to assign that three to a variable individually like this;
$X=2013
$Y=11
$Z=23

Thanks.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Assigning a value to variable

Another newbie to Unix scripting Q.. How do you assign a value resulting from a command, such as awk, to a variable. I am currently trying:- $awk '{print $1}' file1 > variable1 with no change to $variable1. The line: $awk '{print $1}' file1 does print the first line of the... (3 Replies)
Discussion started by: sirtrancealot
3 Replies

2. Shell Programming and Scripting

Assigning Value of variable

Hi In my shell script, I'm trying to find the line count of a file and assign it to a variable. LINE_COUNT=$(wc -l $FILE_NAME) But when i display LINE_COUNT, i'm getting the linecount concatenated with the file name. I want only the number. How can i get the line count alone ? Someone... (2 Replies)
Discussion started by: janemary.a
2 Replies

3. Shell Programming and Scripting

assigning a variable

hi all, in ksh, how do i assign the output of a find command to a variable, e.g am trying something like this : totalNoFiles=$(print find ./ -name "SystemOut*.log"); but when i echo $totalNoFiles it displays find ./ -name "SystemOut*.log" instead of the total number of... (2 Replies)
Discussion started by: cesarNZ
2 Replies

4. Shell Programming and Scripting

Assigning value to a variable

can we make a global variable and store character values and add other values to that variable ?? for example a="hello, John" and can we add value ". How are you? so a can have "hello, John. How are you?" can someone help me?? (2 Replies)
Discussion started by: bonosungho
2 Replies

5. Shell Programming and Scripting

Assigning value to a variable

Is there any difference between: set variable=39 and variable=39 (1 Reply)
Discussion started by: proactiveaditya
1 Replies

6. Shell Programming and Scripting

Removing a character from a variable and assigning it to another variable?

Hi folks. I have this variable called FirstIN that contains something like this: 001,002,003,004... I am trying to assign the content of this variable into ModifiedIN but with the following format : 001 002 003 004...(changing the commas for spaces) I thought about using sed but i am not... (17 Replies)
Discussion started by: Stephan
17 Replies

7. Shell Programming and Scripting

problem in assigning value to variable have value fo other variable

my script is some thing like this i11="{1,2,3,4,5,6,7,8,9,10,11,}" echo "enter value" read value ..............suppose i11 x="$value" echo "$($value)" .............the echo should be {1,2,3,4,5,6,7,8,9,10,11,} but its showing "i11" only. plz help me out to get desired... (10 Replies)
Discussion started by: sagar_1986
10 Replies

8. Shell Programming and Scripting

Assigning file to a variable

Hi, I have a list of files in a directory. Each file has a .txt and a .log extension i.e. file.txt & file.log, file1.txt & file1.log etc. The file with the .log extension may not always exist alongside the file with the .txt extension. I need to copy the .txt file if there is a corresponding... (6 Replies)
Discussion started by: brunlea
6 Replies

9. Shell Programming and Scripting

Assigning value to a variable

Unable to get the value to a variable. set -x cd $HOME echo "Enter the server name" read a echo $a i=4 j=1 k = ps -ef | awk '/server1/{ print $4 }' | tail -$i | head -$j` echo $k When I do the same in command line it works, however the same does not work when I provide that in the... (1 Reply)
Discussion started by: venkidhadha
1 Replies

10. Shell Programming and Scripting

Assigning a variable

I have a date column as 06302015 but I need to have variable which extracts 063015. Am trying something like below but it is not assigning Please let me know if am missing something. Thanks in advance. ################################ #!/usr/bin/ksh DT=06302015 ... (7 Replies)
Discussion started by: weknowd
7 Replies
HODIE(1)							   User Manuals 							  HODIE(1)

NAME
hodie - Print current date and time... in Latin SYNOPSIS
hodie [ OPTION ]... DESCRIPTION
hodie prints out the current date using classic Latin, and in addition also prints it out and time using Roman numerals. OPTIONS
-h, --help Print short help message with syntax -v, --verbose Print months and days (pridie, Kalends, Nones, Ides) full and not the respective abbreviations (standard mode of operation) Two occurrences of -v as well as the use of -vv or --extremely-verbose will include the numerals where applicable fully declined, as in 'ante diem quintum Kalends Septembres'. -n, --numerals Don't print anything in Latin - only the date and time as Roman numerals. -x, --force-numerals Print both the verbose latin and the date and time as Roman numerals. -c, --classic, --auc Print the year in the classic manner ab urbe condita instead of the more modern anno domini . -a, --ante-diem Print the date expressing the number of days to the next main day with the ante diem expression instead of ablative case. -d, --date Print out any date. This has a rather special syntax, with a keyword following the -d flag choosing input format. See section on DATE INPUT below. -r, --republican OFFSET Print out the date dated ab urbe tua condita with the offset counted in years as compared to the modern european kalendar (originat- ing with the hypothetical birth of christ). hodie -r -753 would be equivalent with hodie -c --version Print out the version number of this release and exit. No matter whether other options appear on the command line or not. DATE INPUT
Following the -d or the --date option flags, the first item must be one of the following: verbose In this case, the year, month and day are given by following the verbose keyword by the flags -y, --year, -m, --month, -d, --day for year, month and date respectively ymd After this flag, the date comes in the format YYYY-MM-DD , where the numbers may be separated by any non-numeric character. dmy With this flag, the date is given as DD-MM-YYYY mdy With this flag, the date is given as MM-DD-YYYY Restrictions on the characters that may replace the hyphen apply as above. HISTORY
The story began on the 10. of August, 2000 (a.d. VI Id. Iul., MM). Having finished most of my assignment for my two-month summer job at Ericsson Eurolab Deutschland, Nuremberg, I was idling around on the Internet, and stumbled over the dotcomma-challenges <http://www.dot- comma.org> , where especially the Roman numeral challenge started my mind. Almost an hour hacking, and there it was, another hour, and the language support was there. Before the night was over, I had written this man page and had the layout of a decent Makefile drawn out mentally. At the end of the next day, I was so far that I actually had the workings of RPM worked out, constructed a .rpm-package and a .src.rpm- package, which was promptly released on my home-page, announced on freshmeat and uploaded to metalab (apps/misc :-). Response was quick and plentiful. By now, I have compilation reports from Linux, FreeBSD and SCO Unixware 7; there are a few compability issues to put aside, but it works surprisingly well. RETURN VALUES
hodie returns zero. Always. If it doesn't, then something is really bad with the code. For some really unreadable code, this means that hodie could be used as a strange replacement for true BUGS
It doesn't sanity check the input... telling hodie to display the roman form of the 99th of march gives a slightly jumbled output, which most definitely does not make sense. Reports are more than welcome (e-mail below). AUTHOR
Now, who would come up with such a thing? Well, I'm Mikael Johansson, a rather all-round geek from Stockholm. I'm gravely interested in languages, in computers and in mathematics; a combination more dangerous than you might think. E-mails to <mikael@johanssons.org> SEE ALSO
date(1) Linux AUGUST 2000 HODIE(1)
All times are GMT -4. The time now is 02:19 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy