Basic commands

ls: Lists the contents in the current directory

cd [file path]: Move to a directory

pwd: List your current directory

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
Moving to home directory with the cd command
What directory am I in?
/home/lwu1822
Moving to my vscode directory
What directory am I in?
/home/lwu1822/vscode
What files are within this directory?
APCSA  APCSP  fastpages  spring_portfolio  test

Variables

To create variables, simply assign a value to a variable name.

Ex: x=5

Reference variables with $[var]

text="Hello World!"
echo "$text"
Hello World!

Note: Single and double quotes are different!

See example below

text="Hello World!"
echo "$text"
echo '$text'
Hello World!
$text

Python versions

python --version
python2 --version
Python 3.9.12
Python 2.7.18

Java versions

java --version
javac --version
openjdk 11.0.16 2022-07-19
OpenJDK Runtime Environment (build 11.0.16+8-post-Ubuntu-0ubuntu120.04)
OpenJDK 64-Bit Server VM (build 11.0.16+8-post-Ubuntu-0ubuntu120.04, mixed mode, sharing)
javac 11.0.16

Playing with some Regex

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
Check for packages starting with 'j' and ends with the letter 's'
jupyterlab_pygments
jupyterlab_widgets

Jupyter Check

jupyter --version
jupyter kernelspec list
Selected Jupyter core packages...
IPython          : 8.2.0
ipykernel        : 6.9.1
ipywidgets       : 7.6.5
jupyter_client   : 6.1.12
jupyter_core     : 4.9.2
jupyter_server   : 1.13.5
jupyterlab       : 3.3.2
nbclient         : 0.5.13
nbconvert        : 6.4.4
nbformat         : 5.3.0
notebook         : 6.4.8
qtconsole        : 5.3.0
traitlets        : 5.1.1
Available kernels:
  bash          /home/lwu1822/.local/share/jupyter/kernels/bash
  java          /home/lwu1822/.local/share/jupyter/kernels/java
  javascript    /home/lwu1822/.local/share/jupyter/kernels/javascript
  python3       /home/lwu1822/anaconda3/share/jupyter/kernels/python3

Conda check for Jupyter

conda list | grep jupyter
jupyter                   1.0.0            py39h06a4308_7  
jupyter_client            6.1.12             pyhd3eb1b0_0  
jupyter_console           6.4.0              pyhd3eb1b0_0  
jupyter_core              4.9.2            py39h06a4308_0  
jupyter_server            1.13.5             pyhd3eb1b0_0  
jupyterlab                3.3.2              pyhd3eb1b0_0  
jupyterlab_pygments       0.1.2                      py_0  
jupyterlab_server         2.10.3             pyhd3eb1b0_1  
jupyterlab_widgets        1.0.0              pyhd3eb1b0_1  
(I have checked Slack :))
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
  python3       /home/lwu1822/anaconda3/share/jupyter/kernels/python3


Hacks

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)"
Python 3.9.12
java-common

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
2022-05-15-07-21-16.png  README.md        _notebooks  assets
2022-05-15-07-24-25.png  _action_files    _pages      docker-compose.yml
2022-05-15-07-25-15.png  _config.yml      _plugins    images
Gemfile                  _fastpages_docs  _posts      index.html
LICENSE                  _includes        _sass
Makefile                 _layouts         _word