Re: string to date KSH



vishu wrote:
Could you please explain the following code in brief words.
Ed Morton wrote:

Rafael The Engel wrote:

Hello everyone,
I need your help

I have a string the contains a date "20061024"

I wand to convert it to 24/10/2006

$ date="20061024"

A string assignment.

$ tmp="${date%??}"

Strip the last two characters "24" from string 'date', store the
remainder "200610" in 'tmp'.

$ echo "${date#??????}/${tmp#????}/${tmp%??}"

Three parts separated by '/' are printed;
- strip first (#) six characters from 'date' leaving "24"
- strip first (#) four characters from 'tmp' leaving "10"
- strip the last (%) two characters from 'tmp' leaving "2006"

Janis

24/10/2006

Regards,

Ed.


.



Relevant Pages

  • Re: Calculus XOR Probability
    ... 0:142857....142857.142857...142857 with remainder of 1 ... which is the sort of sequence that you seem to ... doesn't terminate after a finite number of digits. ... creates an ambiguous number at the finite end of the string, ...
    (sci.math)
  • RE: Extreme calculations
    ... Sub largemultiply() ... Remainder = Divide ... Function Multiply(parm1 As String, ... If shift> 0 Then ...
    (microsoft.public.excel.programming)
  • RE: Extreme calculations
    ... Sub largemultiply() ... Remainder = Divide ... Function Multiply(parm1 As String, ... If shift> 0 Then ...
    (microsoft.public.excel.programming)
  • Re: Un - Concatenate ?
    ... > My problem - to unconcatenate - to split a string into its leftmost ... > character and the remainder. ... > I guess I can strip the leftmost alpha/numeric character from the string ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Selecting street name from address field
    ... the simplest way is to use InStr() to find the ... first space, and Midto return the remainder of the string, e.g. ...
    (microsoft.public.access.gettingstarted)