![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| 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 !! |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
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
|
||||
|
||||
|
Aga, you are breaking the rules with duplicate posting:
http://www.unix.com/shell-programmin...ing-lines.html Also, this seems like homework. |
|
#3
|
|||
|
|||
|
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
|
|
#4
|
||||
|
||||
|
You are breaking a rule:
Quote:
If somebody else gives you the solution, you will not learn. |
|
#5
|
|||
|
|||
|
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
|
|||
| Google The UNIX and Linux Forums |
| Thread Tools | |
| Display Modes | |
|
|