how to remove delimiter and append as one string
Hi,
got another question :) i'm trying to create a wrapper script which enables the user to enter the date and time in the following manner: date: 2011-06-31 time: 13:24 which needs to be converted into the following format: date: 20110631 time: 132400 (00 need to add seconds ass 00) can someone please give me some guidance in approaching this? i'm purely doing this to educate myself. it doesn't really add any value but i'd like to know how to do it. thanks! |
This may do it for you if you are using bash:
Code:
date=2011-06-31 |
Bash is much easier than that:
Code:
date=2011-06-31 |
Code:
date=`echo $date | sed -e "s/-//g"` |
Another attempt using the cut command would be
Code:
DATE="$inputDATE" ## ex. inputDATE=2011-09-07 http://lifehacker.com/179514/geek-to...-cygwin-part-i Altrernatively simple would be filtering using grep Code:
newDATE=`echo "$inputDATE" | grep -o '[0-9]' | tr -d '\n'` |
Thanks guys!
|
All times are GMT -5. The time now is 07:23 AM. |