Find the answer to your Linux question:
Results 1 to 4 of 4
Hi there, I'm new to linux programming. I've read a similar post about my problem but the solution given by the other members is using awk command. I have to ...
  1. #1
    Just Joined!
    Join Date
    Oct 2007
    Posts
    8

    How to create table without awk command ?

    Hi there, I'm new to linux programming. I've read a similar post about my problem but the solution given by the other members is using awk command. I have to solve the same problem without using awk commands. Anybody can help me with the sed commands if I'm not mistaken will do the same thing ?

    Question: I need to create a table out from /etc/passwd file with following format:-

    User Name User User Group ID Home
    --------------- ------- --------------- -----------
    John 234 23 /home/john

    Any kind soul out there can help me ? Thanks a lot.

  2. #2
    Linux Newbie radoulov's Avatar
    Join Date
    Sep 2007
    Posts
    111
    Code:
    { printf "%-20s\t%s\t%s\t%s\n" "UserName" "UserID" "GroupID" "Home"
    	while IFS=: read -r un p uid gid j h s;do
    		printf "%-20s\t%d\t%d\t%s\n" "$un" "$uid" "$gid" "$h"
    	done</etc/passwd;}

  3. #3
    Just Joined!
    Join Date
    Oct 2007
    Posts
    8
    thanks a lot radoulov, that was a quick reply! my problem is solved.

  4. #4
    oz
    oz is online now
    forum.guy
    Join Date
    May 2004
    Location
    arch linux
    Posts
    18,095
    Sorry but it's against the forum rules to post homework/classwork questions:

    http://www.linuxforums.org/forum/lin...ums-rules.html

    oz

    new members/users: read this first | new member faq
    no private messages requesting computer support - post them on the forums!
    please use the "report post" button to alert our forum admins to problematic posts rather than responding to them yourself.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...