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

Re: Help with wc and subtraction needed

Very sweet that work perfect, thanks!

On 7/12/07, Todd Zullinger <tmz pobox com> wrote:
Matthew Benjamin wrote:
> I have a command that I am trying to read a particular amount of
> lines with
> wc -l somefile | awk '{print $1}'
> when it givs the number of lines, I am trying to find out how to use
> that number in an addition problem. Can someone help me with that?

lines=$(wc -l somefile | awk '{print $1}')
res=$(($lines + 42))

That's bash specific, so depending on how portable you want the script
to be, you'd need to do things slightly differently.  There are a ton
of ways you could do something like this.  Some bash guides might be

BASH Programming - Introduction HOW-TO

Advanced Bash-Scripting Guide

Todd        OpenPGP -> KeyID: 0xBEAF0CE3 | URL: www.pobox.com/~tmz/pgp
I advise you to go on living solely to enrage those who are paying
your annuities. It is the only pleasure I have left.
    -- Voltaire

fedora-list mailing list
fedora-list redhat com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list

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