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

Re: "fields" in files



On Sunday 30 January 2011 21:59:03 Paul E Condon wrote:
> On 20110130_134532, Axel Freyn wrote:
> > Hi Lisi,
> >
> > On Sun, Jan 30, 2011 at 12:18:39PM +0000, Lisi wrote:
> > > On Sunday 30 January 2011 11:35:56 Camaleón wrote:
> > > > On Sun, 30 Jan 2011 11:26:16 +0000, Lisi wrote:
> > > > > In teh following:
> > > > > -rw-r--r-- 1 lisi lisi    19503 2011-01-28 21:12
> > > > > Etch_repositories.odt
> > > > >
> > > > > I can see eight pieces of information: permissions, directory or
> > > > > file (information that is also at the beginning of the
> > > > > permissions), owner, group (or group, owner), size, date, name of
> > > > > file or directory.
> > > > >
> > > > > What are these called?  I have always called them fields, but it
> > > > > would appear that I am wrong to do so.
> > > >
> > > > directory/file
> > > > user perms-group perms-others perms
> > > > user-group
> > > > size
> > > > last modified timestamp
> > > > file name
> > > >
> > > > I call them "file attributes" but not sure if that's the technical
> > > > name though :-)
> > >
> > > Thanks, Camaleón!  Yes ,that it what they are in this context.  But in
> > > more general terms, like page, chapter, section etc., rather than the
> > > names of that particular page etc. -  what are they called?  I want to
> > > use it with cut if possible, but can't even find if there is a suitable
> > > option when I don't know what they are called.  Column is too narrow
> > > (in the physical sense) a definition.  There are 21 of what cut calls
> > > columns in the name of the file alone in this sample!
> >
> > Is that what you want to achieve?
> >
> > ls -l | sed -e 's/  */ /g'  | cut -f 8 -d " "
>
> This give the file name field.
> An alternative is:
> ls -l | tr -s ' ' | cut -f 8 -d ' '
>
> But beware. If the file name contains embedded space(s), it will
> give only the leading part up to the first space. To get the whole
> file name, use:
> ls -l | tr -s ' ' | cut -f 8- -d ' '
>
> If you are interested in processing the date and time fields, be
> aware that the detailed format that is used depends on how old
> the file is at the time of execution of 'ls'. I get around this
> pandering to human traditions by defining shell variable
>
> TIME_STYLE=+%Y%m%d_%H%M%S
>
> This combines date and time-of-day into a single field. A file
> of data about files using this, remains correct when reconstructed
> at a later date. A full-up geek design decision with no concession
> to human frailty would be to use
>
> TIME_STYLE=+%s
>
> This gives seconds since UNIX epoch. Which might be useful if you are
> collecting data from computers that are operating in different time
> zones.
 Thanks, Paul. :-)

Lisi



Reply to: