Skip to content

Instantly share code, notes, and snippets.

@zfhxi
Last active March 15, 2023 16:19
Show Gist options
  • Save zfhxi/79658216f17e3fc43b6bc6cbdcceb56e to your computer and use it in GitHub Desktop.
Save zfhxi/79658216f17e3fc43b6bc6cbdcceb56e to your computer and use it in GitHub Desktop.
批量替换复制conda环境时bin文件默认解释器
#!/bin/bash
BIN_PATH=$1/bin
PYTHON_INTERPRETER="#!$(realpath $BIN_PATH/python)"
for file in $BIN_PATH/*
do
if [[ $(file -b "$file") == *"Python script"* ]];then
sed -i "1s|.*|$PYTHON_INTERPRETER|g" $file
fi
done
@zfhxi
Copy link
Author

zfhxi commented Mar 15, 2023

How to use it?

$ cd /xxx/miniconda3/envs
$ ls
demo_py38

$ ./modify_interpreter.sh demo_py38

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment