BLP Unit 3.2
BLP Unit 3.2
Relative pathname
- Relative path is defined as the path related to the present working directory (pwd).
- It starts from current directory .
- Relative paths do not start with the root directory i.e. /
- These are usually shorter than absolute paths.
- For example, if you are currently in the home directory of "BLP" and want to access a file
named "example. txt" in a subdirectory called "documents", the relative path would be
"documents/example.txt".
- The cat command in Linux is a versatile companion for various file-related operations,
allowing users to view, concatenate, create, copy, merge, and manipulate file contents.
- Syntax:
- cat [OPTION] [FILE]
Here,
- [OPTION] : represents various command-line options.
- [FILE] : the name of the file(s) to be processed.
- more command is used to view the text files in the command prompt, displaying one
screen at a time in case the file is large.
- The more command also allows the user do scroll up and down through the page.
- When the output is large, we can use more command to see output one by one.
- Syntax:
more [file_name]
- lp stands for ‘Line printer’ which allows to print the files through the terminal.
- This command is also known as the printer management command in Linux.
- Syntax:
lp [options][filename]
- For e.g. lp –d abc.txt
- -d option is used to print the file using the default printer.
1. Wc -l: This option prints the number of lines present in a file. With this option wc
command displays two-columnar output, 1st column shows number of lines present in a
file and 2nd itself represent the file name.
2. Wc – w: This option prints the number of words present in a file. With this option wc
command displays two-columnar output, 1st column shows number of words present in a
file and 2nd is the file name.
3. Wc -c: This option displays count of bytes present in a file. With this option it display
two-columnar output, 1st column shows number of bytes present in a file and 2nd is the
file name.
4. Wc -m: Using -m option ‘wc’ command displays count of characters from a file.
5. Wc -L: It can be used to print out the length of longest (number of characters) line in a file.
- cmp command is used to compare the two files byte by byte and helps you to find out
whether the two files are identical or not.
- When cmp is used for comparison between two files, it reports the location of the first
mismatch to the screen if difference is found and if no difference is found i.e the files
compared are identical.
- cmp displays no message and simply returns the prompt if the files compared are identical.
- Syntax: cmp [option] File1 File2
- comm command compares two sorted files line by line and write to standard output.
- It writes the lines that are common and the lines that are unique.
- Syntax: comm [option] File1 File2
- comm produces three-column output where first column contains lines unique to FIile1
,second column contains lines unique to File2 and third column contains lines common to
both the files.
- comm command only works right if you are comparing two files which are already sorted.