Emertxe-News & Blog

Home » Linux » Cut Command : Filtering What You Want
Cut Command : Filtering What You Want
Cut command in Linux

As a sequel to the previous article about Split command, thought of sharing another useful command called ‘cut’ that is available in Linux environment.

Similar to split, often we run into some situations where configuration to be read from a particular file which is delimited with some identifiers (ex: comma or colon symbol) where the cut command comes into picture. While the cut offers multiple options, for simple understanding purpose, the following syntax helps to split based on the colon as delimiter.


cut –d <delimiter> -f<field name>

Let us take for example cut_demo file (which is a local copy of /etc/password) file in linux which is de-limited by “:” as delimiters, which can be split as follows.



Fig1: Contents of /usr/password


Suppose we are only interested in the first field (that is name field) that can be obtained as follows

 cut –d”:” –f1 cut_demo


Fig2: Obtaining only username using cut command

The output of the command is nothing but the username, cut form the file /etc/password is displayed in the standard output. A sample output provided below. By re-directing it to a different file, further processing on username can be done by a user program. While the split command helps the user to partition contents at file level, the cut command helps and programmer to partition the contents from inside the file, using particular delimiters.

I hope you are able to appreciate practical usage of split and cut command in the past two blog posts. Like cut command in linux let us explore more useful commands in future posts.




Emertxe’s Online Training Programs in Embedded Systems & IoT

Emertxe’s Online Training Programs in Embedded Systems & IoT

The reason why Emertxe is the best choice for career advancement: eLearning and Online training programs are the way forward in the COVID-19 disrupted world. Riding along the digital revolution will ensure engineers are future-ready with skills to not only secure but...

Our Training Programs for Freshers

Our Training Programs for Freshers

Introduction: Emertxe is the leading training institute in Bangalore for Embedded Systems and IoT domains. It is a pioneer in training freshers since 2003 by providing excellent placement opportunities for freshers. Over the years 70000+ students have made their...