Bash Regular expression replace (regexp)

Splinch

You can easily use bash to search-and-replace on variables…

f="/home/alice/myfile.md"
$ echo ${f//.md/.pdf}
/home/alice/myfile.pdf

$ echo ${f//alicee/bob}
/home/alice/myfile.md

$ echo ${f////-}
-home-alice-myfile.md


 

This entry was posted in English Content, Knowledgebase, Unix and tagged , . Bookmark the permalink.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.