![]() |
|
|
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 |
| Need explanation of script | vishalpatel03 | Shell Programming and Scripting | 0 | 11-25-2007 05:55 PM |
| tr explanation please | convenientstore | Shell Programming and Scripting | 1 | 05-31-2007 12:42 AM |
| Explanation of running this script | sendhilmani | Shell Programming and Scripting | 2 | 03-21-2006 03:07 AM |
| AWK explanation | penfold | Shell Programming and Scripting | 2 | 04-05-2005 10:46 PM |
| any explanation for thsi shell script behaviour | xiamin | Shell Programming and Scripting | 9 | 11-09-2001 01:13 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Script explanation
I have the following script Code:
awk '$1 ~ /^[A-Z]*[0-9]+/ {
s += $NF;
m++
}
END {
print NR, m, s
}
and I use it to get results from the following file A4792 4 COMP9021 5 K9 7 ABC 8 924 1 R2D2 3 6 JQL-636 2 I was expecting to get as result 8 3 16 but ir gives me 9 6 26 Can somebody explain me why firstly NF gives 9 instead of 8 when there are 8 records in the file. What does the red + means and generally why I have these results. Please help me, I am new in the scripting art and I want understand to go a step further. Cheers |
|
||||
|
Quote:
|
|
||||
|
Sorry but still I have a question.
With your explanation it shouldn't count the line with the empty field $1 (it was misstyped and couldn't been seen the <tab> so the line was <tab> 6) and the R2D2<tab>3. But it count's them. Why? |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|