[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Adding Files to a New Directory to the Repository

From: Mark E. Hamilton
Subject: Re: Adding Files to a New Directory to the Repository
Date: Mon, 06 Mar 2006 17:29:13 -0700
User-agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.7.12) Gecko/20050920

FWIW, when I do 'cvs rlog -R .' it asserts:

cvs: recurse.c:642: do_recursion: Assertion `strstr (repository, "/./") == ((void *)0)' failed.
cvs [rlog aborted]: received abort signal

I'm using 1.11.19

John Smith wrote:
I tried:
cvs rlog -R . | grep '^cvs rlog:' | awk '{print $NF}'
but the grep returns 0 lines because everyline of cvs rlog -R . starts
with cvs rlog.

No, every line of 'cvs rlog -R' does not start with 'cvs rlog'. Only the directory lines start with 'cvs rlog', and they are written to stderr, not stdout. So, the grep in your pipe above will find nothing in stdout that matches the pattern, and so pass nothing on to awk.

This might work better (assuming you're using bash/ksh)

cvs rlog -R . 2>&1 >/dev/null | awk '{print $NF}'

or this, if you really want to use grep

cvs rlog -R . 2>&1 | grep '^cvs rlog:' | awk '{print $NF}'

furthermore, I don't think $NF returns the # of fields as it is
supposed to in awk.

I don't know that much about awk, but if you think that you're wrong.


head -n 1 output.txt | awk -F"|" '{print $NF}'

prints a blank line.

the following prints "B":
head -n 1 output.txt | awk -F"|" '{print $3}'


Well the 'System Variables' section of O'Reilly's 'Sed & Awk' book says that NF is the number of fields, and $NF is the contents of the last field. Experimenting with this I get:

% echo '|A|B|C|D|' | awk -F"|" '{print NF}'
% echo '|A|B|C|D|' | awk -F"|" '{print $NF}'

which is exactly what the book says I should get. The reason my second example (and your first one) prints a blank line is because the last field (the one following the last '|') is empty.

OTOH, according to the 'Records and Fields' section of the same book the '$' is the field operator, where $n refers to field n. So $NF in these examples is the same as $6 (since NF is 6.) The reason that your second example returns a 'B' is that the third field field (the one to the right of the second '|') is 'B'. (The first field, to the left of the first '|', is empty.)

% echo '|A|B|C|D|' | awk -F"|" '{print $3}'
% echo '|A|B|C|D|' | awk -F"|" '{print $1}'

Mark E. Hamilton
Orion International Technologies, Inc.
Sandia National Laboratory, NM.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]