The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Displaying specific lines in a file. MaestroRage UNIX for Dummies Questions & Answers 3 02-05-2008 01:57 PM
displaying/ counting lines aga Shell Programming and Scripting 2 08-08-2007 12:35 AM
counting the number of lines nayeemmz Linux 6 01-19-2005 09:37 AM
Counting lines and files jorge.ferreira UNIX for Dummies Questions & Answers 6 12-11-2003 08:24 AM
help with displaying certain lines rooh UNIX for Dummies Questions & Answers 3 07-27-2001 07:20 AM

Closed Thread
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 08-07-2007
aga aga is offline
Registered User
 

Join Date: Aug 2007
Posts: 7
displaying/ counting lines

I have a file called xx with the env redirected into it 5 times:
env >> xx
env >> xx
env >> xx
env >> xx
env >> xx
I have to read an input file (here: xx) and look for occurrences of the current user who is executing this script. Once finding an occurrence of the username I have to take that line and append it to a file and display a line number and a bracket against the saved line. The file should look lie that:
1) PWD=...
2) USER=...
3) MAIL=...
4) LOGNAME=...
5) HOME=...
6) PWD=...
7) USER=...
8) MAIL=...
9) LOGNAME=l...
10) HOME=...
I can not use temporary file, sed, awk...

Can somebody help me

So far I' ve got something like this:

echo "Give the name of the file: "
read fileName
egrep -w "PWD" $fileName | cat -b >> $fileName
egrep -w "USER" $fileName | cat -b >> $fileName
egrep -w "MAIL" $fileName | cat -b >> $fileName
egrep -w "LOGNAME" $fileName | cat -b >> $fileName
egrep -w "HOME" $fileName | cat -b >> $fileName
Forum Sponsor
  #2  
Old 08-07-2007
Shell_Life's Avatar
Registered User
 

Join Date: Mar 2007
Location: Bahia, Brazil
Posts: 695
Aga, you are breaking the rules with duplicate posting:
http://www.unix.com/shell-programmin...ing-lines.html

Also, this seems like homework.
  #3  
Old 08-07-2007
aga aga is offline
Registered User
 

Join Date: Aug 2007
Posts: 7
Sorry...I just do not know how to get the output which I need to...I don't know how to print the number of line with a bracket against of it that's all I want to know....
  #4  
Old 08-07-2007
Shell_Life's Avatar
Registered User
 

Join Date: Mar 2007
Location: Bahia, Brazil
Posts: 695
You are breaking a rule:
Quote:
(6) Do not post classroom or homework problems.
Ask you teacher or another classmate.

If somebody else gives you the solution, you will not learn.
  #5  
Old 08-07-2007
aga aga is offline
Registered User
 

Join Date: Aug 2007
Posts: 7
I don't want a strict solution...I just want to have some tip how can I solve my problem...believe me I've tried many options but I still cannot have the output I need to I am a beginner with a UNIX that is why I need some advice...
Google The UNIX and Linux Forums
Closed Thread

Thread Tools
Display Modes




All times are GMT -7. The time now is 01:59 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0