- Structure of a terminal command
- type
- piping into grep
- & = run command in background
- fg = get program from background and put into forground
echo "In this folder is $(ls)"
ln -s src/file.sh dst/myProgram
Symlinks in bin? Or programs themselves in bin?
You should already have some environment variables which exist. Try echoing them out!
echo $HOME
and
echo $EDITOR
You can also export new variables, or overwrite existing ones.
export EDITOR="vim"
- i = insert mode
- esc = normal mode
- arrow keys = move cursor
- / = search
- vaw = select a word
- daw = delete a word
But most importantly...
- :q = quit
- :wq = save & quit
- :!q = quit without saving
function yank(){
xclip -sel clip < $1
}
Math?
echo "$((1 + 2))"
Logic?
AND
mkdir test_folder && cd test_folder
OR
mkdir test_folder || echo "Didnae work!"
Look! we have control flow!
a=2
b=3
if [ a == b ] then
echo 'a'
else
echo 'b'
fi
Using regex!
[[ "2" =~ '[0-9]' ]]
echo most recent exit code
echo $?
Loops
for file in *.md do
cat $file
done
while true do
echo "help im stuck"
done
(( i=10 )); while (( i > 0 )) do
echo "$i bottles of beer on the wall"
sleep 1
((i--))
done
echo th{e,a}n
echo myshow_episode_{0..4}