How to Use Unix Cut Command

Просмотров 14 460
Добавлено: 39 дней назад
Встроить видео
Добавьте следующий код на свою страницу, чтобы встроить это видео:
<iframe src="http://tng.pw/embed/229832/" width="650" height="405" frameborder="0"></iframe> <br />
<a href="http://tng.pw//229832/">How to Use Unix Cut Command</a>
Видео входит в курсы: видео урок Unix

In this tutorial, we will teach you on how to use the UNIX cut command.

Don't forget to check out our site http://howtech.tv/ for more free how-to videos!
http://youtube.com/ithowtovids - our feed
http://www.Facebook.com/howtechtv - join us on Facebook
https://plus.google.com/103440382717658277879 - our group in Google+

Cut command is basically used to select or extract a chunk of text from a particular file. You can do that by specifying a particular range where the text is present in the file. You can even specify specific characters.

Step 1 -- Use the cat command

Follow this step by step guide to learn how to use the Unix cut command.

For example in this tutorial, we have used the cat command first to display the output of the text file on the screen.

Step 2 -- Use the cut command

Next, we will use the cut command along with the different attributes. For example, if we type -c1 -c5 along with the cut command, it will only display the first through the fifth character of each line in the text file. In this manner, you can use use the cut command with attributes in Linux.

Step 3 -- Use the b switch

Similarly, we can use the b switch to fetch a range or single bytes of data from the text file. For example, we might want to display the first and the third character in the text file.

For that, we will type -b1,-3 followed by the name of the text file.

In this manner, only the first and the third character of each line is displayed on the screen over here.

Step 4 -- Use the d switch

We can use the d switch along with the cut command to output data on the screen. We can even specify the range of fields that we want to be included in the output. For the purpose of this tutorial, we would be displaying the first field of each line in the text.

Similarly, we can change the value of the field switch to display the second field of the text file as well by changing the f1 to f2. In this manner, you can use the cut command in Linux.