Last active
August 29, 2015 14:27
-
-
Save davetapley/2de1c6a93548bcaffd8a to your computer and use it in GitHub Desktop.
Substring Replacement in Bash
This file contains hidden or 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
# Works okay: | |
FILE=something.txt; echo ${FILE/txt/log} | |
# Works okay: | |
find . -name \*.txt -exec sh -c 'FILE={}; echo ${FILE}' \; | |
# Fails with 'sh: 1: Bad substitution': | |
find . -name \*.txt -exec sh -c 'FILE={}; echo ${FILE/txt/log}' \; | |
# Works | |
find . -name \*.txt -exec bash -c 'FILE={}; echo ${FILE/txt/log}' \; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment