Others
Shell Scripting for Linux
A Tutorial
Today, I would like to write about Shell Scripting for Linux derived from some references. It started with the definition itself. Shell in a Linux operating systems is like an interface. It is accessed by a terminal to take input (i.e. program, commands, scripts) and gives an output. When terminal is run, the Shell issues a command prompt so users can type input and hit the Enter key to execute.
Now, what is Shell Scripting? It is writing series of commands for the shell to execute. Below are the steps in Shell Script.
Creating a file and its content in Linux
a. Use the cat command [cat > file.txt]
b. Press Enter key
c. Add content
d. Save and exit by press Ctrl+D
e. View the file use cat command [cat file.txt]
Copying the file, then rename the second file
Copy the file called file.doc in the current directory as newfile.doc
$ cp file.doc newfile.doc
$ld -l *.doc
Rename the file to newfile2
$ mv newfile newfile2
Making a new directory, move the second file into the directory
Open the terminal application then use mkdir command to create a new directory name dir1
$ mkdir dir1
Move the file into new directory using mv command. For example, to move the newfile2 from current directory dir1 to another directory dir2.
$ mv newfile2 dir2
Removing the first directory
Remove the non-empty directory dir1 and all the files inside, use the rm command with the -r (recursive) option
$ rm -r dirname
Source:
https://www.guru99.com/introduction-to-shell-scripting.html
https://www.cyberciti.biz/faq/create-a-file-in-linux-using-the-bash-shell-terminal/
https://www.cyberciti.biz/faq/copy-command/
https://www.cyberciti.biz/faq/linux-rename-file/
https://www.cyberciti.biz/faq/how-to-make-a-folder-in-linux-or-unix/
https://linuxize.com/post/how-to-move-files-in-linux-with-mv-command/
https://linuxize.com/post/how-to-remove-files-and-directories-using-linux-command-line/