Skip to content

Instantly share code, notes, and snippets.

@petermchale
Last active February 6, 2020 17:03
Show Gist options
  • Save petermchale/48b434a5b92fe9c488d5af1369e1c19f to your computer and use it in GitHub Desktop.
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++
# 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