Re: split variable to insert date



I have a string variable, for ex:
BTID='test.testing.tested.txt'
I need to split this variable in 2 :

Hi Tom,

one nice way to do it in BASH is:

$ BTID='test.testing.tested.txt'
$ var1=${BTID%.*}
$ var2=${BTID##*.}
$ echo $var1
test.testing.tested
$ echo $var2
txt

BranoZ

.



Relevant Pages

  • Re: Echo to column position
    ... specific column positions consistently? ... I've got VAR1 & VAR2 that can ... echo using tabs or spaces, but this shifts the VAR2 position a bit ... depending on the value in VAR1. ...
    (microsoft.public.windows.server.scripting)
  • Re: [PHP] string as file
    ... This is an example of $var1 and $var2. ... echo include 'template.php'; ... "Some men are born to greatness, some achieve greatness, ...
    (php.general)
  • Re: does a variable contain...
    ... Is there a way, in bash, to determine if the value in var1 contains the string "From"? ... I suppose I could echo it into a temporary file and grep for "From" but that seems a little less than optimal. ...
    (comp.unix.shell)
  • Re: Division [maybe a bug]
    ... echo $var1 // Return -24651656 ... $var2 return the correct result, but $var1 is wrong (the correct ... "Protect your digital freedom and privacy, eliminate DRM, ...
    (php.general)
  • Re: Division [maybe a bug]
    ... jo opp wrote: ... echo $var1 // Return -24651656 ... $var2 return the correct result, but $var1 is wrong (the correct ...
    (php.general)