Last active
July 3, 2024 23:40
-
-
Save OriLiMu/cd34f7f695ca48c132e00b7b2f4034e1 to your computer and use it in GitHub Desktop.
This file contains 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
#!/bin/bash | |
# file content should be | |
#key:value1 | |
#key:value2 | |
# Read the key-value pairs from the file | |
data=$(cat file.txt) | |
# Search for a key using fzf | |
selected_key=$(echo "$data" | awk -F ':' '{print $1}' | fzf) | |
# Output the corresponding value for the selected key | |
selected_value=$(echo "$data" | grep "^$selected_key:" | awk -F ':' '{print $2}') | |
echo "Key: $selected_key, Value: $selected_value" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment