How to extract the date strring and time string into seperate variables in the shell script, after reading the file as the input?
I want to get the variables as in:
dateStr = 20100531
timeStr=142528
for furter processing for validation.
Thanks.,
---------- Post updated at 02:19 AM ---------- Previous update was at 02:04 AM ----------
Thanks for your help.
nawk version of the script worked for me.
Thanks once again.
---------- Post updated at 03:31 AM ---------- Previous update was at 02:43 AM ----------
Hi.,
I am with other concern about the same question which I initially posted.
Actually I tested the above things by hard coding name of the file in the script. But I want it to be dynamically placed into the script.
Actually after reading file name from the shell, the i/p var acts as the file as against to string. So how to treat the file _ name as the string?
#!/bin/ksh or bash
F="name_abc_20100531_142528.txt"
IFS="_." # delimiters are _ and .
f=($F) # parse string to the array f, id 0 = 1st fld
echo "Date ${f[2]} Time ${f[3]}"