How to Use Unix Cut Command

Опубликовано: 25 Сентябрь 2013
на канале: HOWTECH
30,874
251

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!
   / ithowtovids   - our feed
  / howtechtv   - join us on Facebook
https://plus.google.com/1034403827176... - 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.


Смотрите видео How to Use Unix Cut Command онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь HOWTECH 25 Сентябрь 2013, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 30,874 раз и оно понравилось 251 людям.