User Tools

Site Tools


2018cmd_list

A running list of BASH commands, syntax, and environmental variables

This page will be updated with new concepts for each lecture.

Commands

Command/Program Description example/syntax
9/4/18 - Scripting, executable permissions/conventions.
chmod Change the mode of a file or directory chmod MODE FILE
chmod OCTAL-MODE FILE
echo “echo” values to the screen echo “string $varname”
nano Edit a file nano FILE
rev reverse input stream echo “abcd” | rev
touch Update file modification time. Create file if necessary touch FILE
tr Translate or delete characters tr [SET1] [SET2]
which Location of an executable in your PATH which ls
9/6/18
9/11/18

Environmental Variables

Variable name Description example/syntax
9/4/18 - Scripting, executable permissions/conventions.
HOME Your home directory. Same as tilde (~) /home/yourname
PATH Search path for executables. /bin:/usr/bin:$HOME/bin
PS1 Your prompt string. [\h \w]
PWD Your current directory, same as pwd ~/dev
USER Your login/account, same as whoami eid@colostate.edu
9/6/18
9/11/18

Syntax

Keyword(s)/Operators Description Example
9/4/18 - Scripting, executable permissions/conventions.
[ ] conditional [ -z “” ]
if,then,else,fi flow control if [ -z “” ]; then echo 'empty!'; else echo 'NOT empty!'; fi
test flow control test -z “”
&& || boolean operators for flow control [ -z “” ] && echo 'empty!' || echo 'NOT empty!'
9/6/18
let arithmetic assignment a=1; let a=a+1;
$((expr)) arithmetic expressions echo $((a+1))
while loop a=0; while [ $a -lt 10 ]; do echo $a; let a=a+1; done
for var in list loop for num in 1 2 3; do echo $num; done
9/11/18
2018cmd_list.txt · Last modified: 2018/09/07 10:33 by david