Position is specified and the ending position is omitted.Ībove command prints starting position to the fifth character.
$ cut -c 1-7 state.txtĪbove cut command prints first seven characters of each line from the file.Ĭut uses a special form for selecting characters from beginning upto the end of the line:Ībove command prints starting from first character to end. $ cut -c 2,5,7 state.txtĪbove cut command prints second, fifth and seventh character from each line of the file. Here, k denotes the starting position of the character and n denotes the ending position of the character in each line, if k and n are separated by “-” otherwise they are only the position of character in each line from the file taken as an input. It is necessary to specify list of character numbers otherwise it gives error with this option. Tabs and backspaces are treated as a character. This can be a list of numbers separated comma or a range of numbers separated by hyphen(-). This selects the characters given to the -c option. c (column): To cut by character use the -c option. In this, -3 indicate from 1st byte to 3rd byte of a lineĢ. In this, 1- indicate from 1st byte to end byte of a line It uses a special form for selecting bytes from beginning upto the end of the line: List with ranges $ cut -b 1-3,5-7 state.txt List without ranges $ cut -b 1,2,3 state.txt Tabs and backspaces are treated like as a character of 1 byte. It is necessary to specify list of byte numbers otherwise it gives error. Range of bytes can also be specified using the hyphen(-).
b(byte): To extract the specific bytes, you need to follow -b option with the list of byte numbers separated by comma. ISRO CS Syllabus for Scientist/Engineer Examġ.ISRO CS Original Papers and Official Keys.GATE CS Original Papers and Official Keys.