UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 5th, 2006, 08:23 PM
spezialize spezialize is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2005
Posts: 218 spezialize User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 10 h 21 m 15 sec
Reputation Power: 3
Highlighting and copying a line to a file

I want to copy a line from the passwd file into a file. how do i go about this?

Reply With Quote
  #2  
Old March 9th, 2006, 07:16 PM
Ehlanna's Avatar
Ehlanna Ehlanna is offline
Not a clue what to put ...
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2006
Location: in front of this keyboard
Posts: 814 Ehlanna User rank is Captain (20000 - 30000 Reputation Level)Ehlanna User rank is Captain (20000 - 30000 Reputation Level)Ehlanna User rank is Captain (20000 - 30000 Reputation Level)Ehlanna User rank is Captain (20000 - 30000 Reputation Level)Ehlanna User rank is Captain (20000 - 30000 Reputation Level)Ehlanna User rank is Captain (20000 - 30000 Reputation Level)Ehlanna User rank is Captain (20000 - 30000 Reputation Level)Ehlanna User rank is Captain (20000 - 30000 Reputation Level)Ehlanna User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Weeks 2 Days 5 h 10 m 43 sec
Reputation Power: 243
Simple answer is something of the order of:

command /etc/passwd > /your/output.file

That, obvioulsy makes no sense - it all depends on what line, how you want to find it, or them. If, for example you want to copy the line for the user "spezialize" then you would use:

grep spezialize /etc/passwd > /your/output.file

Except, of course, that may not do exactly what you wish - it would copy every line that contained spezialize into the output file. A look at the man pages will soon allow you to do something like:

grep "^spezialize:" /etc/passwd > /your/output.file

Which would ONLY copy any line in the /etc/passwd file that started with (denoted by the ^) the string spezialize: - the : is used at the end of the strinf as that i sused in the passwd file as a field delimiter - this we are saying only copy to the output file the line in the file that relates to the user spezialize (since we know that the username field is the first in the file).

Getting different lines out, depending on what you are looking for would 'just' need a different search string in a grep command and/or further processing - all of which would come down to what you are after.

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > Highlighting and copying a line to a file


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway