Re: [SLUG] LINUX character parsing problem.

From: Eben King (eben01@verizon.net)
Date: Tue May 11 2010 - 00:14:36 EDT


On Mon, 10 May 2010, leebc wrote:

> Thus Ron Youvan hast written on Sun, May 09, 2010 at 10:23:54PM +0000, and, according to prophecy, it shall come to pass that:
>> PreNameA=$(grep -a -A1 Ver.1.00 $FileName | cut -b 160-172 ) > /dev/null
> <snip><snip>
>
>> A line from a typical image file: (these are all Nikon *.nif files)
>> <
>> ...t.2...........J.......................i.........à.%.........H...........Ì..........................NIKON
>> CORPORATION...NIKON D90......,.......,....Ver.1.00 ...2010:04:14
>> 12:21:28...û\..ûÔ...........ÿ.......
>>
>> Immediately following the "Ver.1.00" is "2010:04:14 12:21:28" the date
>> and time information in the order that I wish to use, year, month and day,
> <snip>
>
>> My problem is that I want to use "so many characters" after the "Ver.1.00"
>> not "so many characters after the beginning of the greped line," (which
>> sometimes is different) but cut works based on "so many character after the
>> start of the line."
>>
>> How can I select N characters after the "Ver.1.00" in a greped line?
>
> I'm a little surprised that someone hasn't already replied with "Use Awk
> to XYZ..." ;-)
> I'm a grep person.

I'm a sed person.

(grep 1.00, etc) | sed 's/^.*\(1\.00.*\)$/\1/'

and now, 1.00 is at the beginning of the line; IOW a predetermined location.

> The first line is stderror, so
> > mydate=`exiftags -i dsc08759.jpg |grep "Image Created:" |cut -c16-`
> exiftags: maker note not supported
> > echo $mydate
> 2010:04:24 19:26:00
> works.

What does that do that

exiftags -i dsc08759.jpg 2>/dev/null | grep "Image Created:" | cut -c 16-
or | colrm 15

doesn't? It's got no dbl-quotes so it would only get the first word (I
think), but is that significant?

> I recommend not using ":"'s in filenames.

Especially if they're going through a Macintosh.

> Often when dealing with binary files, od is one of the ONLY ways to
> usefully view them.
> I once had a file where I was trying to grep for a the string "ERROR".
> Grepping for "E" would return the line, but nothing longer would. When
> I finally ran the file through od I found that there were nulls between
> EVERY character.

Would

tr -d '\0' < filename | grep ERROR

have worked, or did you want to preserve the other nulls? Or not know ahead
of time that the string was stored in Unicode?

-- 
-eben    QebWenE01R@vTerYizUonI.nOetP    royalty.mine.nu:81
LIBRA:  A big promotion is just around the corner for someone
much more talented than you.  Laughter is the very best medicine,
remember that when your appendix bursts next week.  -- Weird Al
-----------------------------------------------------------------------
This list is provided as an unmoderated internet service by Networked
Knowledge Systems (NKS).  Views and opinions expressed in messages
posted are those of the author and do not necessarily reflect the
official policy or position of NKS or any of its employees.



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 15:23:12 EDT