Cut command in unix (or linux) is used to select sections of text from each line of files.The cut command can be used to print characters in a line by specifying the position of the characters.
1.To print the characters in a line, use the -c option in cut command
Example:
> cat file.txt
unix or linux
is unix good
is linux good
cut command to print characters by position:
cut -c4 file.txt
x
u
l
2.cut command to print characters by range
cut -c4-7 file.txt
prints the character from 4th position to 7th position.
cut -c-6 file.txt
prints the character from first upto 6th.
cut -c10- fil.txt
prints the character from 10th position to till the end.
1.To print the characters in a line, use the -c option in cut command
Example:
> cat file.txt
unix or linux
is unix good
is linux good
cut command to print characters by position:
cut -c4 file.txt
x
u
l
2.cut command to print characters by range
cut -c4-7 file.txt
prints the character from 4th position to 7th position.
cut -c-6 file.txt
prints the character from first upto 6th.
cut -c10- fil.txt
prints the character from 10th position to till the end.
No comments:
Post a Comment