Desk of Contents
A path to a file is to find out the distinctive location of a file or listing in an OS filesystem. You possibly can journey or change the situation of the present listing via a terminal or command line.
In file system, there are two sorts of paths by which you’ll find the listing or a file.
- Absolute Path
- Relative Path
Absolute Path
An Absolute Path is the complete path of the file or listing from root to the file. An Absolute path of any listing at all times begins with a slash (/) representing the listing root.
/dwelling/jatinsharma/Desktop/Bash
Now in case you are within the some listing x
and also you wish to decide absolutely the path of that you just simply run pwd
command which is stands for Print work listing. It offers you absolutely the path of the present listing as proven below-
Relative Path
The Relative Path of a file is its location relative to the present working listing. It by no means begins with a slash (/) or root. It begins with the present work listing.
Desktop/Bash
-
cd .
refers back to the currect listing -
cd ..
strikes the listing again one listing -
cd ~
this ship you to the /root listing -
cd ../..
this sends you the again by two listing -
pwd
prints absolutely the path of the present listing
It doesn’t matter which language you might be utilizing feedback are one of many important issues. In our case, you may as well create feedback within the bash. There are two sorts of comments-
- Single Line Feedback
- Multiline Feedback
Single Line Feedback
To write down single line remark in bash, we now have to make use of hash #
image on the beginning of the remark. Following is an instance of Bash Script which accommodates single-line feedback in between instructions:
# single-line-comment.sh
# !/bin/bash
# This can be a single-line remark in Bash Script.
echo "howdy world"
# echo output, its additionally a single line remark
echo "hiii, good morning"
# That is one other single line remark
Multiline Feedback
In bash there are two methods to put in writing multiline feedback. You should utilize any of them in response to your choice.
Methodology – 1
# multiline-comment.sh
#!/bin/bash
<<COMMENTS
That is the primary remark
That is the second remark
That is the instance of multiline feedback
This isn't going to print on display screen
COMMENTS
echo "Whats up World"
Methodology – 2
# multiline-comment.sh
#!/bin/bash
:'
That is the primary remark
That is the second remark
That is additionally the instance of multiline feedback
'
echo "Whats up World"
Wrapping up
On this article I’ve mentioned in regards to the Absolute and Relative paths and the way you should utilize them and likewise how one can write the Single and Multiline feedback within the bash script.