cut Linux Commands
What is Linux cut Command?
Explanation
cut COMMAND:cut command is used to cut out selected fields of each line of a file. The cut command uses delimiters to determine where to split fields.
SYNTAX :
cut [options]
OPTIONS:
-c |
Specifies character positions. |
-b |
Specifies byte positions. |
-d flags |
Specifies the delimiters and fields. |
EXAMPLE:
Lets create a file file1.txt and let it have the following data:
Data in file1.txt |
This is, an example program,for cut command. |
-
cut -c1-3 text.txt
Output:
Thi
Cut the first three letters from the above line.
-
cut -d, -f1,2 text.txt
Output:
This is, an example program
The above command is used to split the fields using delimiter and cut the first two fields.