Skip to main content

Posts

Showing posts with the label Linux

Learning BASH: Text Processing - Cut Command

Text processing tools in Bash is a huge topic . So we will take it one command at a time.

CUT COMMAND
You might think , CUT means to remove a file from location A to location B. But as the link here says, Cut command in unix (or linux) is used to select sections of text from each line of files. You can use the cut command to select fields or columns from a line by specifying a delimiter or you can select a portion of text by specifying the range or characters. Basically the cut command slices a line and extracts the text.

The definition of CUT command in linux itself says:



Print selected parts of lines from each FILE to standard output.
I created a text file (I am on windows running Cygwin...so......) . Added a few lines.

This is the first line
This is the second
And this is not the last line
Finally we end
Good Bye

The linux help says:


 N N'th byte, character or field, counted from 1
N-from N'th byte, character or field, to end of line
N-Mfrom N'th to M'th (included) byte, charac…