1 00:00:06,519 --> 00:00:10,675 To work with structured text cells efficiently, it can be useful to filter 2 00:00:10,675 --> 00:00:14,830 out specific columns, because many text cells on Linux are organized in columns. 3 00:00:16,170 --> 00:00:22,320 The ETCPass WD file is a nice example. It contains users that are defined on your 4 00:00:22,320 --> 00:00:28,469 system, and cut is an easy to use command that filters out columns from text files. 5 00:00:29,239 --> 00:00:35,320 To do its work properly, you need to specify the field delimiter for cut. That would be the option D. 6 00:00:37,359 --> 00:00:42,473 To understand, compare the result of the command cut f3etcpass wd, 7 00:00:42,473 --> 00:00:47,586 which is trying to filter the third field without specifying the 8 00:00:47,586 --> 00:00:52,700 field delimiter and Compare that to cut D F3 etcpasswd. 9 00:00:53,280 --> 00:00:54,939 You'll see that it is much more efficient. 10 00:00:56,219 --> 00:01:00,179 A utility that you will find a lot in combination with cut is Sort. 11 00:01:01,560 --> 00:01:06,200 Because it sorts the output of the cut command by default in alphabetical order. 12 00:01:07,159 --> 00:01:10,019 You can use the n option to sort in numeric order. 13 00:01:10,780 --> 00:01:15,030 Compare the following, for instance cut d, f3 etc 14 00:01:15,030 --> 00:01:19,280 wdsort and sort n. Let me show you. 15 00:01:21,019 --> 00:01:24,574 So to start with good minus 16 00:01:24,574 --> 00:01:28,129 f3 etcwd is doing what? 17 00:01:28,689 --> 00:01:32,540 Well, nothing that makes sense because cud doesn't know how to recognize the fields. 18 00:01:33,920 --> 00:01:39,530 What we see here, if you look at the last line for user lorry, for instance, first field has the 19 00:01:39,530 --> 00:01:45,140 username, the third field has the user id, and there is more information that we will talk about later. 20 00:01:45,840 --> 00:01:50,984 Now, if I want to tell cut to do this in an efficient way, let's make 21 00:01:50,984 --> 00:01:56,129 that cut d colon there. You can see that it filters out the third column. 22 00:01:56,829 --> 00:02:02,153 Now we can sort that by sending it to sort. But this is an alphabetic sort, 23 00:02:02,153 --> 00:02:07,476 so all ones first, all twos next, all 3s next, and so on. That's not probably 24 00:02:07,476 --> 00:02:12,800 what you want. So make that sort n to make it a nice numeric sort. 25 00:02:13,159 --> 00:02:17,319 And that's how you can use sort and cut, which are two convenient utilities together.