Bourne Again Shell improving on Bourne Shell
pwd
current working directorycd
change directoryls
lists content of directoryls -a
(a=all) includes hidden filesls -l
(l=long) reveals permissionsls -la
all+long- add
h
everywhere = human readable
cat filename
reads the content of the filecat -n
add line numbers
wc
to just get the number of lines, words and charactershead -n x filename
reads the first x lines of the filesort
same ascat
but sorted ; see options to reverse, use specific coloumns, save output, etctouch
creates empty files and edit timestamp (as many as neededtouch f1 f2 f3 ..
)cp source target
copy source to targetmv source target
move source to target (also rename)mv -f
to force and overwrite, no questions asked
rm filename
remove filerm -rf folder
remove folder forcingly with recursion (ie delete all with content)
bonus: history
reveal all commands used (history !number
)
By addimg #!/bin/bash
at the top, this makes a script an executable (e.g. call it in command line as ./myscript.sh) - ensure execution allowed with chmod +rx myscript.sh
Variables are declared with Capitals and then refer to them with $. For positional argument just use a counter, for instance echo "username? $1"; echo "password? $2";
#!/bin/bash
DISPLAY = "running copy script"
echo = $DISPLAY
for include in [some char to match]; do
cp -- "$include"* test/
done