Given a string file path such as /foo/fizzbuzz.bar, how would I use bash to extract just the fizzbuzz portion of said string?
Given a string file path such as /foo/fizzbuzz.bar , how would I use bash
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Here’s how to do it with the # and % operators in Bash.
${x%.bar}could also be${x%.*}to remove everything after a dot or${x%%.*}to remove everything after the first dot.Example:
Documentation can be found in the Bash manual. Look for
${parameter%word}and${parameter%%word}trailing portion matching section.