Notice: Undefined variable: meta in /home/customer/www/demo.emertxe-group.com/public_html/wp-content/themes/Divi-child/functions.php on line 1116

Deprecated: implode(): Passing glue string after array is deprecated. Swap the parameters in /home/customer/www/demo.emertxe-group.com/public_html/wp-content/plugins/divi-filterable-blog-module/includes/controller/autoloader.php on line 94
Cut command : Filtering what you want - Emertxe Custom

Emertxe-News & Blog

Home » Linux » Cut command : Filtering what you want
Cut command : Filtering what you want
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.

  1.                                 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.

cut_screenshot_1

Fig1: Contents of /usr/password

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

  1.                                 cut –d”:” –f1 cut_demo

cut_screenshot_2

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. Let us explore more useful commands in future posts.

Best Embedded systems training institute with placements in Bangalore.

YOU MAY ALSO LIKE

The Future of Embedded Systems : Trends and Predictions

The Future of Embedded Systems : Trends and Predictions

Introduction Embedded systems have become an integral part of modern technology, and their importance is increasing day by day. These systems are designed to perform specific tasks and are embedded in everyday devices, making them intelligent and interactive. From...

Online Free IoT Internship for Engineering Students – 2023

Online Free IoT Internship for Engineering Students – 2023

The Internship Ecosystem An internship is a type of professional learning opportunity where engineering students get practical work related to their field of study or career interest. Through an internship, a student can explore and advance their career while...

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *