Scenario:
#!/usr/bash/ksh
source_dir=/usr/idmp/bbp/
filename = "SURH00000321312"
insertText = `IDD`
I want the result like this SUIDDRH00000321312
. How to add the insertText
variable into a file name.
Scenario:
#!/usr/bash/ksh
source_dir=/usr/idmp/bbp/
filename = "SURH00000321312"
insertText = `IDD`
I want the result like this SUIDDRH00000321312
. How to add the insertText
variable into a file name.
This does what you ask:
This works by selecting substrings of the variable
filename
starting at an offset and continuing for a length via the shell form:${parameter:offset:length}
Compatibility
Substring expansion works under
ksh
,bash
, andzsh
but notdash
ortcsh
.Alternate way from sed: