Two ways to name a column
cut selects parts of each line in one of two modes. In byte or character mode, selected with -c, you name positions such as 1-3 or 5. In field mode, selected with -f, cut splits each line at a delimiter and names fields by number. The delimiter is set with -d, and it must be a single character. The default delimiter is a tab.
Field mode is the one you will use for structured text. Position mode is useful for fixed-width data such as the output of some system tools, where each column starts at the same character offset on every line.
Fields with a delimiter
A password-style file uses colons between fields. The example below builds a tiny one, then selects the first and third fields.
printf 'lice:x:1001\nbob:x:1002\n'> users.txt
cut -d: -f1,3 users.txtThe output is alice:1001 and bob:1002. The output delimiter is the same as the input delimiter, which is the default behavior. Use --output-delimiter to change it, for example to print a space or a tab between the selected fields.
cut does not collapse repeated spaces. With a space delimiter, two spaces in a row produce an empty field. For text aligned with several spaces, squeeze the spaces first with tr -s, which is covered in a later unit, or use awk.
Character positions
Position mode uses -c. A range such as 1-3 selects the first three characters, and a list such as 1,5 selects two single characters. A range that starts with a dash selects from the beginning, and one that ends with a dash selects to the end of the line.
printf '026-12-05 INFO ok\n'| cut -c1-10This prints the date, 2026-12-05. Positions are counted in characters for the locale in use, so a line that contains multibyte characters can give a different result under different settings. For ASCII logs it is safe.
paste: joining files side by side
paste reads several files and joins their lines, one line from each file per output line, separated by a tab. It is the opposite of cut, and it is useful when two lists must be combined row by row. The -d option changes the separator, and -s joins all the lines of one file into a single line.
printf 'ed\ngreen\nblue\n'> names.txt
printf '\n2\n3\n'> codes.txt
paste -d, names.txt codes.txtThe result is three lines: red,1, green,2, and blue,3. If the files have different lengths, paste fills the shorter side with empty fields. Keep the two lists in the same order, because paste does not match rows by content. For matching by a key, use join or awk.
column: making a table readable
column is a formatting tool. With -t it arranges the input into aligned columns, splitting on whitespace by default. With -s you choose the input delimiter, so column can align a comma-separated file without you doing the padding by hand. It comes from util-linux, which is installed in the lab.
column -s, -t < table.csvIf you create a small CSV with a name column and a count column, this command prints each row with the columns padded to the widest value. The output is for people to read, not for other programs, because the padding is not a stable format. Keep the raw data in a file and align it only for display.
Choosing between cut and awk
cut is the right tool when the delimiter is a single, consistent character and you only need to select fields. It is short, fast, and easy to read in a pipeline. When the delimiter is a run of spaces, when you need to test a value before selecting it, or when you need to reorder or combine fields, awk is the better choice. The two tools answer the same question for simple inputs, so pick the one whose behavior you can predict on messy data.
A good test is to feed the tool a line with an empty field in the middle. cut returns an empty string for that field, which is what you asked for. awk with the default separator skips the extra spaces entirely, so the field numbers shift. Neither result is wrong, but the difference matters when a file was produced by a program that pads its columns. Knowing which behavior you have is what keeps a report correct.
paste has a similar split of responsibilities. It does not look at content at all. It only pairs lines by their position in each file, so it is a good way to rebuild a table from separate columns, and a poor way to join two files by a shared key. For keyed joins, the join utility or an awk program with an array lookup is the right design, and a later unit in this module shows the array approach.
Putting the tools together
A common pipeline selects a column, then aligns the result. The example below takes the first and third fields of a colon-separated file and aligns them for display.
cut -d: -f1,3 users.txt | column -s: -tThe -s: option tells column that the input is split on colons, because column -t alone splits only on whitespace and would leave these rows unchanged. The output is the same two rows as before, now aligned in two columns separated by spaces. The pattern of select, join, and align is one you will see again in the sort and awk units.