LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-03-2009, 01:41 AM   #1
ilinuxnewbie
LQ Newbie
 
Registered: Aug 2009
Posts: 2

Rep: Reputation: 0
creating table


hi all
i am a linux newbie. please tell me how this code works.

1st statement is clear to me. what does the while IFS statement do.
what is IFS? read -r? un p uid gid j h s;?

Also what does the last statement done</etc/passwd do??

{ 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;}

Please reply .. just now trying to learn linux.. plz
 
Old 08-03-2009, 01:53 AM   #2
Meson
Member
 
Registered: Oct 2007
Distribution: Arch x86_64
Posts: 606

Rep: Reputation: 67
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;}
The </etc/passwd is directing the file /etc/passwd into the read command in the while loop.

IFS=: is setting the Internal Field Separator to :. It is normally a newline, tab, and space. The read command takes a line of input and stores each 'field' into the variables un p uid gid j h and s. So again, IFS=: is saying that fields are separated by colons, not by spaces like normal.
 
Old 08-04-2009, 12:15 AM   #3
ilinuxnewbie
LQ Newbie
 
Registered: Aug 2009
Posts: 2

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Meson View Post
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;}
The </etc/passwd is directing the file /etc/passwd into the read command in the while loop.

IFS=: is setting the Internal Field Separator to :. It is normally a newline, tab, and space. The read command takes a line of input and stores each 'field' into the variables un p uid gid j h and s. So again, IFS=: is saying that fields are separated by colons, not by spaces like normal.
hi meson,

Now its making sense. Later if i 've any doubts in linux, then i will raise it here. once again thanks..
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
doesn't contain a valid partition table after creating raid1 via kickstart ncsuapex Linux - Software 3 01-22-2009 11:26 AM
creating table headers in bash panchosansa Programming 3 10-16-2006 05:22 AM
Latex Help - Tabular creating vertical holes in table maneeshsethi Linux - Software 3 08-20-2004 09:13 PM
Need help creating routing table on linux itrap2003 Linux - Networking 5 06-25-2004 10:18 PM
How to import MS ACCESS Table including OLE filed into the MySQL Table ? myunicom Linux - General 1 11-28-2003 12:30 PM


All times are GMT -5. The time now is 02:06 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration