2022-08-25 Bash Notes
echo "Using conditional statement to create a project directory and project"
# Variable section
export project_dir=$HOME/vscode # change vscode to different name to test git clone
export project=$project_dir/APCSA # change APCSP to name of project from git clone
export project_repo="https://github.com/nighthawkcoders/APCSA.git" # change to project of choice
cd ~ # start in home directory
# Conditional block to make a project directory
if [ ! -d $project_dir ]
then
echo "Directory $project_dir does not exists... makinng directory $project_dir"
mkdir -p $project_dir
fi
echo "Directory $project_dir exists."
# Conditional block to git clone a project from project_repo
if [ ! -d $project ]
then
echo "Directory $project does not exists... cloning $project_repo"
cd $project_dir
git clone $project_repo
cd ~
fi
echo "Directory $project exists."
- "cat" command shows you text from inside the file
- "env" shows enviroment
- ".git" hidden file that keeps track of your merges, basically keeps your machine and the github cloud server in check to see when files need to change
export PATH=~/anaconda3/bin:$PATH
# conda not found without this command
echo Conda Check
# test for a kernel installation
test="google" # keyword
check=`conda list | grep $test` # run command
n=${#check} # determine length
if [[ ${n} > 0 ]]; # testt length
then # greater than zero
echo "$check"
else # less than zero
echo "$test not found"
fi
test="bash" # keyword
check=`jupyter kernelspec list | grep $test` # run command
n=${#check} # determine length
if [[ ${n} > 0 ]]; # testt length
then # greater than zero
echo "$check"
else # less than zero
echo "$test not found"
fi
test="python3" # keyword
check=`jupyter kernelspec list | grep $test` # run command
n=${#check} # determine length
if [[ ${n} > 0 ]]; # testt length
then # greater than zero
echo "$check"
else # less than zero
echo "$test not found"
fi
cd $project
echo "Updating.............."
git pull