![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Grep help | flood | Shell Programming and Scripting | 3 | 06-06-2008 02:14 AM |
| Grep | Aejaz | UNIX for Advanced & Expert Users | 3 | 04-30-2008 08:10 AM |
| grep | dineshr85 | Shell Programming and Scripting | 1 | 10-10-2007 05:52 AM |
| how to exclude the GREP command from GREP | yamsin789 | UNIX for Advanced & Expert Users | 2 | 10-05-2007 03:59 AM |
| Make grep -c display like grep -n? | Jerrad | Shell Programming and Scripting | 2 | 08-25-2006 01:20 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
grep wc
Hello, I am trying add all occurances of the current user into an ouputfile in a numbered list e.g. 1 ) username......
I have a problem thou, the grep seach word count is not assigning a number to the lineno variable, this is a problem and I can not seem to get it to work with various brackets and speech marks. Please help this is very frustrating. echo "What file to search? " read file int=1 echo "starting Grep" lineno=grep $USER $file | wc -l set -- `grep $USER $file` while [ $int -le $lineno ] do eval y='$'$int echo "$int ) $y" >> usernameoutput int=`expr $int + 1` done echo "finished" |
|
||||
|
Hello again,
Havent responded for a while not had much time to play with this lately. And now that I return to have another go, I have the same problem. lineno= grep -c '$user' '$file' I don't think it is reading the file variable correctly, as at the top i have added: echo "$file" which returns what I expect it to, confirming that the file given by the user is valid and its reading the variable and not looking for the word file. But when it comes to the grep count: grep: $file: No such file or directory username: line 26: [: 1: unary operator expected Am I correct in thinking that the unary operator error is a result of the lineno variable being stored as a string and not as a int? Please can someone confirm the line which will store the total count of the grep command taking user and file as arguments in a varable called lineno. This is driving me potty!! Thanks for any help! |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|