Created
April 12, 2021 06:20
-
-
Save stroehleina/b9498a2c61d422f818aed0c83ce7de44 to your computer and use it in GitHub Desktop.
Function that can be added as an alias to your ~/.bashrc to find all conda environments that contain a particular package (and optionally version)
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
#Usage: conda-find.sh my-lost-package my-version | |
conda info --envs | | |
grep -v "#" | | |
sed 's/\s\+/\t/' | | |
cut -f2 | | |
sed '/^$/d' | | |
sed 's/^\*\s\+//' | | |
while read line; do | |
conda list -p $line | | |
grep -v "#" | | |
awk -v env=$line '{print env"\t"$0}' ; | |
done | | |
awk -v look=$1 -v ver=$2 '{if($2 == look){if(ver != ""){if($3 == ver){print $0}}else{print $0}}}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment