Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Replace integer string in a variable based on month? Post 303025808 by RudiC on Monday 12th of November 2018 02:36:52 PM
Old 11-12-2018
Yes - 3.2.25(1) is too old.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Converting a String variable into Integer

Hi, I am passing a variable to a unix function. However when I try to assign the value to another variable like typeset -i I_CACHE_VAL=$2 Is this because of String to Integer conversion? I get an error. Please help me with thsi. Thanks (2 Replies)
Discussion started by: neeto
2 Replies

2. Shell Programming and Scripting

Using sed to replace a string in file with a string in a variable that contains spaces

Hi, i call my shell like: my_shell "my project name" my script: #!/bin/bash -vx projectname=$1 sed s/'PROJECT_NAME ='/'PROJECT_NAME = '$projectname/ <test_config_doxy >temp cp temp test_config_doxy the following error occurres: sed s/'PROJECT_NAME ... (2 Replies)
Discussion started by: vivelafete
2 Replies

3. Shell Programming and Scripting

replace (sed?) a string in file with multiple lines (string) from variable

Can someone tell me how I can do this? e.g: a=$(echo -e wert trewt ertert ertert ertert erttert erterte rterter tertertert ert) How do i replace the STRING with $a? I try this: sed -i 's/STRING/'"$a"'/g' filename.ext but this don' t work (2 Replies)
Discussion started by: jforce
2 Replies

4. Shell Programming and Scripting

how to compare string integer with an integer?

hi, how to I do this? i="4.000" if ; then echo "smaller" fi how do I convert the "4.000" to 4? Thanks! (4 Replies)
Discussion started by: h0ujun
4 Replies

5. Shell Programming and Scripting

sed or awk command to replace a string pattern with another string based on position of this string

here is what i want to achieve... consider a file contains below contents. the file size is large about 60mb cat dump.sql INSERT INTO `table1` (`id`, `action`, `date`, `descrip`, `lastModified`) VALUES (1,'Change','2011-05-05 00:00:00','Account Updated','2012-02-10... (10 Replies)
Discussion started by: vivek d r
10 Replies

6. Shell Programming and Scripting

Converting Month into Integer

okay so i run an openssl command to get the date of an expired script. Doing so gives me this: enddate=Jun 26 23:59:59 2012 GMT Then i cut everything out and just leave the month which is "Jun" Now the next part of my script is to tell the user if the the certificate is expired or not... (6 Replies)
Discussion started by: shade917
6 Replies

7. Shell Programming and Scripting

Moving files based on size (string to integer)

I have a log file that I want to archive out as it reaches 100MB. I am using the following to get the file size into a variable but get the error "line 5: filesize=$(wc -c < logfile.log) if then echo "is greater than 100M" else echo "is less than 100M" fi I'm sure there's something... (2 Replies)
Discussion started by: Flakman
2 Replies

8. Shell Programming and Scripting

Find and replace string based on entries on another file

I have a file1 with different with multiple fields and records File2 has 2 fields. I want to find and replace strings in file1 based on file2 values (I Want an exact match i.e. for example: when searching for DT:3, Substr of DT:34 should not be matched) File2: DT:3 foo_err DT:34 bar_frr... (8 Replies)
Discussion started by: aydj
8 Replies

9. Shell Programming and Scripting

Replace variable value in first file based on records in second

Hello , I have below files a) File A <?xml version="1.0" encoding="UTF-8" standalone="no"?> <root xmlns="http://aaa/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema" version="2.0"> <project name="source"> <mapping name="m_Source"> <parameter... (3 Replies)
Discussion started by: Pratik4891
3 Replies

10. Shell Programming and Scripting

Replace a string based on input

I am trying to read a value from a mapping file and would need to replace the value based on country parameter source_table_@ctry_final Expected final_var=source_table_aus_final If the country is in nz,usa,uk then final_var=diff_table_nz_final final_var=diff_table_usa_final like that... (10 Replies)
Discussion started by: Master_Mind
10 Replies
IDATE(3)								 1								  IDATE(3)

idate - Format a local time/date as integer

SYNOPSIS
int idate (string $format, [int $timestamp = time()]) DESCRIPTION
Returns a number formatted according to the given format string using the given integer $timestamp or the current local time if no time- stamp is given. In other words, $timestamp is optional and defaults to the value of time(3). Unlike the function date(3), idate(3) accepts just one char in the $format parameter. PARAMETERS
o $format - The following characters are recognized in the $format parameter string +------------------+---------------------------------------------------+ |$format character | | | | | | | Description | | | | +------------------+---------------------------------------------------+ | | | | B | | | | | | | Swatch Beat/Internet Time | | | | | | | | d | | | | | | | Day of the month | | | | | | | | h | | | | | | | Hour (12 hour format) | | | | | | | | H | | | | | | | Hour (24 hour format) | | | | | | | | i | | | | | | | Minutes | | | | | | | | I (uppercase i) | | | | | | | returns 1 if DST is activated, 0 otherwise | | | | | | | | L (uppercase l) | | | | | | | returns 1 for leap year, 0 otherwise | | | | | | | | m | | | | | | | Month number | | | | | | | | s | | | | | | | Seconds | | | | | | | | t | | | | | | | Days in current month | | | | | | | | U | | | | | | | Seconds since the Unix Epoch - January 1 1970 | | | 00:00:00 UTC - this is the same as time(3) | | | | | | | | w | | | | | | | Day of the week ( 0 on Sunday) | | | | | | | | W | | | | | | | ISO-8601 week number of year, weeks starting on | | | Monday | | | | | | | | y | | | | | | | Year (1 or 2 digits - check note below) | | | | | | | | Y | | | | | | | Year (4 digits) | | | | | | | | z | | | | | | | Day of the year | | | | | | | | Z | | | | | | | Timezone offset in seconds | | | | +------------------+---------------------------------------------------+ o $timestamp - The optional $timestamp parameter is an integer Unix timestamp that defaults to the current local time if a $timestamp is not given. In other words, it defaults to the value of time(3). RETURN VALUES
Returns an integer. As idate(3) always returns an integer and as they can't start with a "0", idate(3) may return fewer digits than you would expect. See the example below. ERRORS
/EXCEPTIONS Every call to a date/time function will generate a E_NOTICE if the time zone is not valid, and/or a E_STRICT or E_WARNING message if using the system settings or the $TZ environment variable. See also date_default_timezone_set(3) CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 5.1.0 | | | | | | | Now issues the E_STRICT and E_NOTICE time zone | | | errors. | | | | +--------+---------------------------------------------------+ EXAMPLES
Example #1 idate(3) example <?php $timestamp = strtotime('1st January 2004'); //1072915200 // this prints the year in a two digit format // however, as this would start with a "0", it // only prints "4" echo idate('y', $timestamp); ?> SEE ALSO
date(3), getdate(3), time(3). PHP Documentation Group IDATE(3)
All times are GMT -4. The time now is 11:33 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy