Here are some additional examples of using the cut command:
-
Extracting the First Field:
cut -d ',' -f 1 /home/labex/project/customers.txtThis extracts the first column from the file, using a comma as the delimiter.
-
Extracting Multiple Fields:
cut -d ',' -f 1,3 /home/labex/project/customers.txtThis extracts the first and third columns from the file.
-
Extracting a Range of Fields:
cut -d ',' -f 2-4 /home/labex/project/customers.txtThis extracts fields 2 through 4 from each line.
-
Using a Different Delimiter:
cut -d ':' -f 1 /etc/passwdThis extracts the first field from the
/etc/passwdfile, using a colon (:) as the delimiter. -
Extracting Characters:
cut -c 1-5 /home/labex/project/customers.txtThis extracts the first five characters from each line of the file.
These examples demonstrate the versatility of the cut command for processing text files. If you need more specific examples or have further questions, let me know!
