This will be more understandable if we take it by an example. Let’s see how many users we have on the system:

linux:~ # cat /etc/passwd
lp:x:4:7:Printing daemon:/var/spool/lpd:/bin/bash
mail:x:8:12:Mailer daemon:/var/spool/clientmqueue:/bin/false
news:x:9:13:News system:/etc/news:/bin/bash
uucp:x:10:14:Unix-to-Unix CoPy system:/etc/uucp:/bin/bash
games:x:12:100:Games account:/var/games:/bin/bash
man:x:13:62:Manual pages viewer:/var/cache/man:/bin/bash
at:x:25:25:Batch jobs daemon:/var/spool/atjobs:/bin/bash
wwwrun:x:30:8:WWW daemon apache:/var/lib/wwwrun:/bin/false
ftp:x:40:49:FTP account:/srv/ftp:/bin/bash
postfix:x:51:51:Postfix Daemon:/var/spool/postfix:/bin/false
sshd:x:71:65:SSH daemon:/var/lib/sshd:/bin/false
ntp:x:74:65534:NTP daemon:/var/lib/ntp:/bin/false
ldap:x:76:70:User for OpenLDAP:/var/lib/ldap:/bin/bash
linux:~ #

Now, what if I need all the users column before the colon. To do so, I’ll run the following command:

linux:~ # cut -d: -f1 /etc/passwd


linux:~ #


As you can see, we have successfully gathered all the users currently on the system.  ‘-d’ option in the command defines the delimiter and it is defined as a colon. Then ‘-f1’ indicates which column we are to take. Here since 1 is mentioned, the first column before the colon is taken and since it is the users on the system, we get the required output. To save this file, you can direct the output of this command to another editor file just as follows:

linux:~ # cut -d: -f1 /etc/passwd > allusers.txt

Adnan Khurshid

Adnan Khurshid, the author of this article, has been working in a telecommunication sector since 2007. He has worked there as a VAS (Value Added Services) engineer and has excelled remarkably in the field. Working in this field has been his passion and he has always made efforts to keep himself up to date. Find more about him on LinkedIn

More Posts

Tags: ,

12 Comments on How to get columns from editor segregated by a delimiter in Linux

  1. kathy says:

    you r good

  2. meet local singles free says:

    check it out bro

  3. aromatherapy says:

    hello, I sent an email to you about this post, its not coming thru for me. Can you connect with me when you get a chance.

  4. Find Out what Happened to Limewire says:

    Thank you for these kinds of a good blog. Where else could one get this sort of facts written in this sort of an incite full way? I have a presentation that I am just now working on, and I have been searching for these kinds of information.

  5. buy tramadol says:

    If you have to do it, you might as well do it right

  6. Italy Tour Packages says:

    I think you have mentioned some very interesting details , regards for the post.

  7. Direct Download Movies says:

    Thanks a ton for posting this, I observed it extremely informative, and it answered most of the concerns I had.

  8. Cosmetic surgery says:

    Really? It really is excellent to witness anyone finally begin addressing this stuff, however I’m still not really certain how much I agree with you on it all. I subscribed to your rss feed though and will certainly keep following your writing and possibly down the road I may chime in once again in much more detail. Cheers for blogging though!

  9. amazon promotional codes says:

    Your weblog seems to be remarkable – complete with excellent posts.. and so forth. I feel you may get even much better good results with incorporating some extra video clips and pictures. What do you believe. Despite the fact that I’ve bookmarked it. Many thanks.

  10. Thanks for taking the time to discuss this, I feel strongly about it and love studying more on this topic. If attainable, as you acquire experience, would you mind updating your blog with additional info? It is extremely helpful for me.

  11. Read More says:

    Various online cooking games are obtainable for children as well.
    This definitely applies to some of the free Diego games that
    you will find on the Internet. If you find
    a site which sells this software but also provides free membership to the site, you have the
    opportunity to learn so much about the arcade game industry, as
    well as getting support for the software, learning from other people through forums.

Leave a Reply