[sf-lug] I need a quick piece of code..
jim
jim at well.com
Thu Dec 31 10:41:31 PST 2009
oh, yeah: also, how can we structure for loops for
these problems?
for <VAR> in <LIST> <COMMANDS>
for i in `seq 1 3 120`
do
head -$i <filename> | tail -1 | cut -d':' -f4
done
On Thu, 2009-12-31 at 10:08 -0800, jim wrote:
> +1
>
> wrt problem definitions, maybe we can come up with
> several common parameters and general cases via email
> before the hoped-for python class that may or may not
> happen at noisebridge from 6:30 PM to 8 PM this coming
> monday (20100104)? (interested in a more-or-less
> intro to python and/or programming in general? this
> class has a flexible and accommodating format to let
> people just jump right in no matter their level.)
>
>
> i like general parametric and problem definitions
> that can be used as specs for a variety of languages,
> (for my interests: shell scripts, c, and python)
> e.g.:
>
> parametric specs:
> * all files are ASCII text files (note that numbers,
> therefore, are strings of text constrained to the
> ten numerals and perhaps the six alpha chars
> (a,b,c,d,e,f) for hex (and if so, uppercase and/or
> lowercase).
> * types of numbers: phone numbers, dates, money,
> results of the four arithmetic operations, output
> of commonly used gnu toolkit commands (e.g. wc)....
> * common flatfile formats (e.g. /etc/passwd, which
> uses both the colon (:) and the comma (,)
> characters as field delimiters, the command line
> (and shell scripts) which typically (tho' not
> necessarily) use the space character as field
> (parameter) delimiters....
> * a filter that can be used to parse the output
> of commands (which commands: who, ps, wc...?),
> probably should exercise the use of the cut
> command if implemented as a shell script: what's
> the python equivalent of the cut command?
> * anything involving the use of the find command
> (what's the python equivalent?).
>
> use case specs:
> * /etc/passwd and /etc/group (maybe the fifth
> field--the "comment" field--if it has
> comma-delimited contact info?).
> * shell scripts (parsing python or perl scripts
> seems a bit beyond).
> * various configuration files, the more regular
> the better (e.g. dns zone files)
> * simple flatfile use cases in which each "record"
> is on a line by itself and for which fields are
> delimited by some one character (and possibly
> allowing a sub-field delimiter, again e.g. the
> fifth field of the /etc/passwd file). this could
> include custom files such as a list of friends
> with contact info and birthdays, a ToDo list with
> dates and chores. again, the more regular the
> better. (i recall that larry wall developed perl
> from the c programs and shell scripts he'd
> created as his own toolkit to "parse" irregular
> text files.
>
> (stop me, i can't help myself...)
>
>
>
>
> On Thu, 2009-12-31 at 07:27 -0800, Alex Kleider wrote:
> > It would be good to have the problem defined.
> > So far the assumption has been that you want to return the last line of a file which you happen to know will be an integer- I'm doubting that that is the real problem.
> > Could it be the more general problem of returning all integers? ..integers on single lines by them selves? .. what are the other possibilities????
> > This seems like the perfect little exercise for the python class held (over the holidays: somewhat irregularly) on Monday evenings.
> >
> > ak
> >
> > --- On Wed, 12/30/09, John F. Strazzarino <jstrazza at yahoo.com> wrote:
> >
> > > From: John F. Strazzarino <jstrazza at yahoo.com>
> > > Subject: [sf-lug] I need a quick piece of code..
> > > To: "SFLUG Mailing List" <sf-lug at linuxmafia.com>
> > > Date: Wednesday, December 30, 2009, 10:25 PM
> > > I
> > > have a three line text file
> > >
> > >
> > > This is a test
> > > blank line
> > > 123456
> > >
> > >
> > > The last line of the file is a number and I need just
> > > that number....
> > >
> > > I know that this must be a combo of tail and grep
> > >
> > >
> > > Can anyone help......nothing fancy is needed...
> > > \\
> > > Thanks
> > >
> > > John
> > >
> > >
> > >
> > >
> > > -----Inline Attachment Follows-----
> > >
> > > _______________________________________________
> > > sf-lug mailing list
> > > sf-lug at linuxmafia.com
> > > http://linuxmafia.com/mailman/listinfo/sf-lug
> > > Information about SF-LUG is at http://www.sf-lug.org/
> >
> >
> >
> >
> > _______________________________________________
> > sf-lug mailing list
> > sf-lug at linuxmafia.com
> > http://linuxmafia.com/mailman/listinfo/sf-lug
> > Information about SF-LUG is at http://www.sf-lug.org/
> >
>
>
> _______________________________________________
> sf-lug mailing list
> sf-lug at linuxmafia.com
> http://linuxmafia.com/mailman/listinfo/sf-lug
> Information about SF-LUG is at http://www.sf-lug.org/
>
More information about the sf-lug
mailing list