old-www/LDP/GNU-Linux-Tools-Summary/html/c8113.htm

500 lines
6.5 KiB
HTML

<HTML
><HEAD
><TITLE
>Mathematical tools</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="GNU/Linux Command-Line Tools Summary"
HREF="book1.htm"><LINK
REL="PREVIOUS"
TITLE="Finding Text Within Files"
HREF="x7969.htm"><LINK
REL="NEXT"
TITLE="Network Commands"
HREF="c8319.htm"></HEAD
><BODY
CLASS="CHAPTER"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>GNU/Linux Command-Line Tools Summary</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="x7969.htm"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="c8319.htm"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="CHAPTER"
><H1
><A
NAME="MATHEMATICAL-TOOLS"
></A
>Chapter 12. Mathematical tools</H1
><P
></P
><DIV
CLASS="NOTE"
><BLOCKQUOTE
CLASS="NOTE"
><P
><B
>num-utils homepage: </B
>The &ldquo;num-utils&rdquo; homepage, <A
HREF="http://suso.suso.org/programs/num-utils/"
TARGET="_top"
>Num Utils,</A
> contains a variety of command line programs that could be useful when performing maths on your GNU/Linux machine.</P
></BLOCKQUOTE
></DIV
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
>units</DT
><DD
><P
><A
NAME="AEN8125"
></A
>Convert <A
NAME="AEN8127"
></A
>units of measurement <A
NAME="AEN8129"
></A
>between different scales.<A
NAME="AEN8131"
></A
> For example, centimeters <A
NAME="AEN8133"
></A
>to inches,<A
NAME="AEN8135"
></A
> litres <A
NAME="AEN8137"
></A
>to gallons.<A
NAME="AEN8139"
></A
></P
><P
>Simply run <A
NAME="AEN8142"
></A
>the program,<A
NAME="AEN8144"
></A
> I recommend <A
NAME="AEN8146"
></A
>running <A
NAME="AEN8148"
></A
>it as follows:<A
NAME="AEN8150"
></A
></P
><PRE
CLASS="SCREEN"
>units --verbose<A
NAME="AEN8153"
></A
></PRE
><P
>This will run the program and it will tell <A
NAME="AEN8156"
></A
>you exactly <A
NAME="AEN8158"
></A
>what it is doing.</P
><P
>Example: you enter <A
NAME="AEN8161"
></A
>&ldquo;60 meters<A
NAME="AEN8163"
></A
>&rdquo; then you want it worked out in &ldquo;kilometers&rdquo;. The first line will tell <A
NAME="AEN8165"
></A
>you what this evaluates <A
NAME="AEN8167"
></A
>to.</P
><P
>If you wanted the conversion <A
NAME="AEN8170"
></A
>rate for &ldquo;meters&rdquo; to &ldquo;kilometers&rdquo; read the second line of the output <A
NAME="AEN8172"
></A
>(which will tell <A
NAME="AEN8174"
></A
>you meters/1000).</P
><DIV
CLASS="NOTE"
><BLOCKQUOTE
CLASS="NOTE"
><P
><B
>To exit: </B
>Press <A
NAME="AEN8179"
></A
>
<B
CLASS="KEYCAP"
>CTRL</B
>-<B
CLASS="KEYCAP"
>D</B
>
<A
NAME="AEN8184"
></A
>
(end-of-file key) when you are finished <A
NAME="AEN8186"
></A
>using <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>units</I
></SPAN
>.</P
></BLOCKQUOTE
></DIV
></DD
><DT
>python</DT
><DD
><P
><A
NAME="AEN8193"
></A
>Python <A
NAME="AEN8195"
></A
>is a very powerful,<A
NAME="AEN8197"
></A
> easy to learn,<A
NAME="AEN8199"
></A
> general <A
NAME="AEN8201"
></A
>purpose, interpreted<A
NAME="AEN8203"
></A
> programming <A
NAME="AEN8205"
></A
>language. And it makes a great <A
NAME="AEN8207"
></A
>calculator! If you don't have a calculator <A
NAME="AEN8209"
></A
>installed<A
NAME="AEN8211"
></A
> then simply type <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>python</I
></SPAN
>, then hit <A
NAME="AEN8214"
></A
>[Enter]. </P
><P
>This will execute <A
NAME="AEN8217"
></A
>the <SPAN
CLASS="ACRONYM"
>Python</SPAN
> <A
NAME="AEN8220"
></A
>interpreter in interactive <A
NAME="AEN8222"
></A
>mode. Type your sums <A
NAME="AEN8224"
></A
>just like you would use a calculator.<A
NAME="AEN8226"
></A
> Note that if you want to work out fractions <A
NAME="AEN8228"
></A
>make sure you use a decimal<A
NAME="AEN8230"
></A
> point and a zero <A
NAME="AEN8232"
></A
>to obtain the correct <A
NAME="AEN8234"
></A
>answer (otherwise it will use integer<A
NAME="AEN8236"
></A
> division).</P
><P
>To start <A
NAME="AEN8239"
></A
>python in interactive <A
NAME="AEN8241"
></A
>mode, simply type:</P
><PRE
CLASS="SCREEN"
>python</PRE
><P
>Once python <A
NAME="AEN8245"
></A
>is started <A
NAME="AEN8247"
></A
>you can use it to add <A
NAME="AEN8249"
></A
>up sums <A
NAME="AEN8251"
></A
>or maybe do some python programming.<A
NAME="AEN8253"
></A
></P
><P
>Use
<B
CLASS="KEYCAP"
>CTRL</B
>-<B
CLASS="KEYCAP"
>D</B
>
<A
NAME="AEN8259"
></A
>
(end-of-file key) to exit <A
NAME="AEN8261"
></A
>the <SPAN
CLASS="ACRONYM"
>Python</SPAN
> <A
NAME="AEN8264"
></A
>interpreter.</P
></DD
><DT
>numgrep</DT
><DD
><P
><A
NAME="AEN8270"
></A
>A little bit <A
NAME="AEN8272"
></A
>like grep <A
NAME="AEN8274"
></A
>only this is designed <A
NAME="AEN8276"
></A
>for numbers <A
NAME="AEN8278"
></A
>only. </P
><P
>Use '/' (forward slashes) to contain each expression.<A
NAME="AEN8281"
></A
> </P
><P
>Use m&lt;n&gt; to find <A
NAME="AEN8284"
></A
>multiples of the number <A
NAME="AEN8286"
></A
>n and use f&lt;n&gt; to find factors<A
NAME="AEN8288"
></A
> of the number n. </P
><P
>Use commas <A
NAME="AEN8291"
></A
>to seperate expressions <A
NAME="AEN8293"
></A
>and .. (two dots) to represent <A
NAME="AEN8295"
></A
>a range.<A
NAME="AEN8297"
></A
> </P
><P
>For example, to input <A
NAME="AEN8300"
></A
>from standard <A
NAME="AEN8302"
></A
>input <A
NAME="AEN8304"
></A
><A
NAME="AEN8306"
></A
>you could simply type:</P
><PRE
CLASS="SCREEN"
>numgrep</PRE
><P
>To input from a file and look <A
NAME="AEN8310"
></A
>for numbers <A
NAME="AEN8312"
></A
>between 1 and 1000 you could type:</P
><PRE
CLASS="SCREEN"
>numgrep /1..1000/ file_name</PRE
><DIV
CLASS="NOTE"
><BLOCKQUOTE
CLASS="NOTE"
><P
><B
>This tool comes from the num-utils package: </B
>Please note that this tool is part of the num-utils package.</P
></BLOCKQUOTE
></DIV
></DD
></DL
></DIV
><P
></P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="x7969.htm"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="book1.htm"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="c8319.htm"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Finding Text Within Files</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
>&nbsp;</TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Network Commands</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>