0

I want to parse out current folder color for papirus folders theme. I have the following string:

List of available colors: black blue bluegrey brown cyan deeporange green grey > indigo magenta nordic orange pink red teal violet white yellow

I have no experience with regex. I want to color after the > i.e. indigo. The color can vary. Can anyone please help me with the regex.

1 Answer 1

1

You don't need a regex, a parameter expansion can do that just fine:

#!/bin/bash
string='List of available colors: black blue bluegrey brown cyan deeporange green grey > indigo magenta nordic orange pink red teal violet white yellow'

color=${string#*> }  # Remove everything up to "> ".
echo ${color%% *}    # Remove everything after the first space.
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.