akaballa
Computer
- May 29, 2011
- 7
Hi I am not sure if I am in the right forum.
I have a quick concern with the sed command.
I am trying to extract a substring from a string in shell script.
This is my code so far:
I just need to extract 20111005. If this case the numbers are in the end. But in some other cases it might be in the middle of the string. Therefore, I chose to use sed.
However, when I run this code, It match the entire $cmdRun string. Please advice!
Regards,
akaballa
I have a quick concern with the sed command.
I am trying to extract a substring from a string in shell script.
This is my code so far:
Code:
cmdRun="-vs LAST_BUS_DAY=20111005"
time_stamp=`echo "$cmdRun" | sed 's/.*([0-9])+.*/\\\\1/'`
echo $time_stamp
I just need to extract 20111005. If this case the numbers are in the end. But in some other cases it might be in the middle of the string. Therefore, I chose to use sed.
However, when I run this code, It match the entire $cmdRun string. Please advice!
Regards,
akaballa