Tools
Seeing if tools are installed.
- Basic commands
- Variables
- Python versions
- Java versions
- Playing with some Regex
- Jupyter Check
- Conda check for Jupyter
- Hacks
echo "Moving to home directory with the cd command"
cd
echo "What directory am I in?"
pwd
echo "Moving to my vscode directory"
cd /home/lwu1822/vscode
echo "What directory am I in?"
pwd
echo "What files are within this directory?"
ls
text="Hello World!"
echo "$text"
Note: Single and double quotes are different!
See example below
text="Hello World!"
echo "$text"
echo '$text'
python --version
python2 --version
java --version
javac --version
echo "Check for packages starting with 'j' and ends with the letter 's'"
# What this bash script does:
# Checks if there is output after grep (searching) for packages starting
# with 'j' and ending with 's'
# First lists all conda packages, then filters to only show the package
# names (excludes Version and Build Channel) with the cut command
# The grep command uses some fun Regex
# ^ means that the character following it (in parenthesis) must start at the
# beginning
# .*: "."" means any character, "*" means match the character before it
# any number of times -> ".*" means match any character any number of times
# $: Character before it (s) must be at the end
if conda list | cut -d " " -f 1 | grep "^j.*s$" ; then
:
else
echo "No packages starting with 'j' and ending with 's'"
fi
jupyter --version
jupyter kernelspec list
conda list | grep jupyter
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 "$check"
fi
To verify tools:
For many packages, you can type the name of the package and then --version
, or you can grep from the dpkg -l
list
java --version
dpkg -l | cut -d " " -f 3 | grep -E "^(java)"
To verify Conda, you can use the conda list
command. I'm not going to do this here because the output is huge, but you can see above where I used regex and grep to search for the specific things I want
main_dir=vscode/
fastpages_dir=fastpages/
cd
cd $main_dir/$fastpages_dir
ls
# git pull origin master