Last active
February 6, 2020 17:03
-
-
Save petermchale/48b434a5b92fe9c488d5af1369e1c19f to your computer and use it in GitHub Desktop.
Insert one string into another in bash; think std::string::insert() in C++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# purpose | |
# ------- | |
# strip directory and suffix (argument 3) from path (argument 1) forming a prefix | |
# return the concatenation of prefix, argument 2, and suffix | |
# usage | |
# ----- | |
# ./insert.sh "dir/file.vcf" ".normalized" ".vcf" | |
# file.normalized.vcf | |
path=$1 | |
middle=$2 | |
suffix=$3 | |
prefix=`basename $path $suffix` | |
echo $prefix$middle$suffix |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment