Unix

Cut Command in Unix/Linux

Cut command in unix is used to select sections of text from each line of files.Extraction of line segments can typically be done by bytes (-b), characters (-c), or fields (-f) separated by a delimiter (-d — the tab character by default).
The syntax of cut command is

The options are
  • -b:Select only the bytes from each line as specified in LIST
  • -c:Select only the characters from each line as specified in LIST
  • -d:Use character DELIM instead of a tab for the field delimiter
  • -f:Select only these fields on each line
  • -s:Do not print lines not containing delimiters
Examples of cut command
  • cut command to print character by position.  
 
The above cut command prints the third character in each line of the file
  • cut command to print character by range. 
 
The above cut command prints the characters from fourth position to the eighthth position in each line.

Powered by Blogger.