Trying to solve this is using way more time than it should!!
I have an input string: <td>10.11.12.13</td> that I want to convert to \folder1\folder2\folder3\**** REMOTE 10-11-12-13 ****.txt. The output string is then created as a file (touch)
I have tried breaking it down to smaller conversion steps, but the best I can get is \folder1\folder2\folder3\**** 10-11-12-13.txt
I have attempted to use both sed and bash built-in string manipulation with no complete success.
The folder names are static, the ip address will be variable.
Code used so far:
Code:
firststr="**** REMOTE "
secondstr=" ****.txt"
myfolder="/folder1/folder2/folder3/"
ipaddress="<td>10.11.12.13</td>"
ipaddress="${ipaddress//[!0-9.]/}"
echo $ipaddress
ipaddress="${ipaddress//./-}"
ipaddress="$myfolder/$firststr$ipaddress$secondstr"
echo $ipaddress
touch $ipaddress
The problem is obviously associated with the words I need in the final file name and the correct use of escape characters. Originally when using the sed and bash string replacements I couldn't get the </td> to convert with the operating system displaying a directory listing after the </td>. Searching on-line I found the allow only numbers code which I expanded to include the period which allowed me to make some progress.
Hopefully others can see the errors in my code and point me in the right direction!!