The cut command in UNIX is a command for cutting out the sections from each line of files and writing the result to standard output. It can be used to cut parts of a line by byte position, character and field. Basically the cut command slices a line and extracts the text. It is necessary to specify option with command otherwise it gives error. If more than one file name is provided then data from each file is not precedes by its file name.
$cut -d "delimiter" -f (field number) file.txt
[opc@instance-2 ~]$ cat myFirstScript.txt pwd This is my FirstScript Once upon a time there lived a great king. He was very kind and have never let any one down. [opc@instance-2 ~]$ cut -d " " -f 1,5 myFirstScript.txt pwd This Once there He and [opc@instance-2 ~]$ cut -d " " -f 1-5 myFirstScript.txt pwd This is my FirstScript Once upon a time there He was very kind and
https://www.geeksforgeeks.org/cut-command-linux-examples/
No comments:
Post a Comment