Bash Scripting
Bash is shell and command language which helps automize the many processes/scripts in Deep Learning experiments. Here we provide a step by step introduction to bash scripting which is an essential tool for a good Deep Learning researcher.
Syntax
Let's start with the syntax in general.
Shebang
The shebang (#!/bin/bash) at the beginning of a script specifies the interpreter to be used when executing the script. The shebang should always be the first line of your script. In this case, /bin/bash is the path to the Bash interpreter.
Comments
Comments in Bash scripts begin with a hash symbol (#) and continue to the end of the line. Comments are ignored by the interpreter.
Command Execution
Commands in a Bash script are executed line by line, just as they would be in a terminal. For example:
echo "This line will be displayed."
mkdir new_directory
Check file size:
du -sh /some/folder
-h for the human readable format, -s for grand total size of the folder.
Create a file:
touch some.py
create a folder:
mkdir some/folder/
Delete a file:
rm some.py
delete a folder
rm -r some/
Rename or move a folder:
mv source/directory/ target/directory/
Copy a file:
cp some/folder/file.py /new/location/
copy a folder:
cp -r some/folder/ /new/location/