Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
hey,
could some1 help me with this?
i am trying to get a word count of lines between lines starting with a letter. the file is like this:AUS_LO
109D
265C
AUS_HO
1078D
1093C
AUS_POso a count of lines from AUS_LO to AUS_HO and count between AUS_HO and AUS_PO.
any help would be really apreciated.

# should be 4
sed -n "/AUS_LO/,/AUS_HO/p" data.file|wc -w# should be 7
sed -n "/AUS_LO/,/AUS_PO/p" data.file|wc -w

thanks for replying,
the names aus_lo and aus_po change all the time, wat the file is is a list of changes between two folders and the numbers are the line number of the changes.
is there anyway to say find numbers between letters? like
sed -n "/[a-z]/,/[a-z]/p" data.file|wc -w

I'm not understanding your question, but it looks like you want to do more processing on data found within a range. sed doesn't do if comparisons well. awk also supports range patterns. The sed example could be rewritten this way:
awk '$1 ~ /AUS_LO/ , $1 ~ /AUS_HO/' data.file|wc -w
If you wanted to act on each line within the range, you could do something like this:
awk '$1 ~ /AUS_LO/ , $1 ~ /AUS_HO/
{
print "do something"
} ' data.file

the file is a list of changes in files, a diff is used to check between 2 folders, the results come back word /numbers/ word e.g.
aus
123c1
546d1
bel
123c1
che
123c2was wondering is there any way to get the amount of changes between the first word and the second so the output would be
aus
2
bel
1
che
1

Assuming that if the first character is alpha it's a file name and if the first character is integer, it's a change, you can set up a break point report using awk - nawk in my case since I'm using Solaris:
#!/bin/ksh
nawk ' BEGIN { cnter=0 }
{
if ($0 ~ /^[a-zA-Z]+/)
{
# print the number of changes if past first line
if (NR > 1)
{
print cnter
cnter=0
}print $0
continue
}if ($0 ~ /^[1-9]+/)
cnter++} END { print cnter } ' datafile.txt
# end scriptI also assume the file ends with a change

![]() |
shell script
|
Remotely Removing a File
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |