Let's say I have a file that looks like:
host[1-2]lx
host[1-4]win
what I want is an easy way to get
host1lx
host2lx
host1win
host2win
host3win
host4win
Is there a neat way to automate that process?
Edit: What I was hoping for is something like using a substitution on host[1-4]win
using the line number, where I can repeat the replacement using the [1-4]
part. Imagine something like
:110s_host\[1-4\]win_host1win\rhost2win\rhost3win\rhost4win\r_
But is there a way to not spell out the four hosts, instead have sed repeat it based on what was found in the [...]
?
.*
. Overall, this sounds more like a task for a scripting language than for an editor. If you run into problems scripting a solution, ask on SO. I'm voting to close as off-topic.112,116s/$/\=line('.')-111/