Help with wc and subtraction needed
Todd Zullinger
tmz at pobox.com
Fri Jul 13 00:37:24 UTC 2007
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
helpful:
BASH Programming - Introduction HOW-TO
http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html
Advanced Bash-Scripting Guide
http://tldp.org/LDP/abs/html/
--
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 542 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/fedora-list/attachments/20070712/6c1e84be/attachment-0001.sig>
More information about the fedora-list
mailing list