ls -l question

ls -l question

Post by Maurice Samue » Thu, 18 Dec 1997 04:00:00



i want to use ls -l to get the date and time stamp off of a file, so i do
a ls -l <filename> and pipe the output to awk and have it print the
$6,$7,and the $8 fields. now my problem is that if the kilobytes field is
greater than 1000000 then the $4th and $5th fields get merged and i have
to print the $5th $6th and $7th field to get the same date and time stamp.
is there anyway to get a date and timestamp of a file without ls -l so i
don't have to worry about awk fields getting merged? any help will be
greatly appreciated. thanks -maurice
 --
   **********************************************************************    
   *                    ___                  LIVE LONG AND PROSPER!     *
   *       ___....-----'---`-----....___                                *
   * =========================================                          *
   *        ___`---..._______...---'___                                 *
   *       (___)      _|_|_|_      (___)   Maurice Samuels              *
   *         \\____.-'_.---._`-.____//     INTERNET:                    *

   *                   ~~~~~                                            *
   *                                                                    *
   *on the WWW try:                                                     *
   *              http://homepage.seas.upenn.edu/~samuels/              *
   **********************************************************************

here are some quotes:

"Lets make sure history never forgets...the name..Enterprise, Picard out."
                                       Captain Picard - STNG

 
 
 

ls -l question

Post by Eric Levene » Thu, 18 Dec 1997 04:00:00


 > i want to use ls -l to get the date and time stamp off of a file, so i do
 > a ls -l <filename> and pipe the output to awk and have it print the
 > $6,$7,and the $8 fields. now my problem is that if the kilobytes field is
 > greater than 1000000 then the $4th and $5th fields get merged and i have
 > to print the $5th $6th and $7th field to get the same date and time stamp.
 > is there anyway to get a date and timestamp of a file without ls -l so i
 > don't have to worry about awk fields getting merged? any help will be
 > greatly appreciated. thanks -maurice

perl can do that. You can find perl binary for any system on the Net.

--

--------------------------------------------------------------------
ric Lvnez              "Felix qui potuit rerum cognoscere causas"

(NeXTMail, MIME)                                   Georgica, II-489
--------------------------------------------------------------------

 
 
 

ls -l question

Post by Somchith Khemmnivan » Thu, 18 Dec 1997 04:00:00


Hi,

Depending on your OS of choice. Try looking at the stat program or stat
function.

Somckit


> i want to use ls -l to get the date and time stamp off of a file, so i do
> a ls -l <filename> and pipe the output to awk and have it print the
> $6,$7,and the $8 fields. now my problem is that if the kilobytes field is
> greater than 1000000 then the $4th and $5th fields get merged and i have
> to print the $5th $6th and $7th field to get the same date and time stamp.
> is there anyway to get a date and timestamp of a file without ls -l so i
> don't have to worry about awk fields getting merged? any help will be
> greatly appreciated. thanks -maurice
>  --
>    **********************************************************************
>    *                    ___                  LIVE LONG AND PROSPER!     *
>    *       ___....-----'---`-----....___                                *
>    * =========================================                          *
>    *        ___`---..._______...---'___                                 *
>    *       (___)      _|_|_|_      (___)   Maurice Samuels              *
>    *         \\____.-'_.---._`-.____//     INTERNET:                    *

>    *                   ~~~~~                                            *
>    *                                                                    *
>    *on the WWW try:                                                     *
>    *              http://homepage.seas.upenn.edu/~samuels/              *
>    **********************************************************************

> here are some quotes:

> "Lets make sure history never forgets...the name..Enterprise, Picard out."
>                                        Captain Picard - STNG

 
 
 

ls -l question

Post by Erwin R. Manue » Thu, 18 Dec 1997 04:00:00


Under bash or ksh, you can try:

ls -l | awk '
{
    if ( length($4) > 6 )
        print $5$6$7
    else
        print $6$7$8

Quote:}

With sh or csh, I believe you need to use \ and ;

A better way may be to use cut:

ls -l | cut -c42-44,45-47,48-53

--
Erwin R. Manuel




>i want to use ls -l to get the date and time stamp off of a file, so i
do
>a ls -l <filename> and pipe the output to awk and have it print the
>$6,$7,and the $8 fields. now my problem is that if the kilobytes field
is
>greater than 1000000 then the $4th and $5th fields get merged and i
have
>to print the $5th $6th and $7th field to get the same date and time
stamp.
>is there anyway to get a date and timestamp of a file without ls -l so
i
>don't have to worry about awk fields getting merged? any help will be
>greatly appreciated. thanks -maurice
> --

**********************************************************************

- Show quoted text -

>   *                    ___                  LIVE LONG AND PROSPER!
*
>   *       ___....-----'---`-----....___
*
>   * =========================================
*
>   *        ___`---..._______...---'___
*
>   *       (___)      _|_|_|_      (___)   Maurice Samuels
*
>   *         \\____.-'_.---._`-.____//     INTERNET:
*

*
>   *                   ~~~~~
*
>   *
*
>   *on the WWW try:
*
>   *              http://homepage.seas.upenn.edu/~samuels/
*

**********************************************************************

- Show quoted text -

Quote:

>here are some quotes:

>"Lets make sure history never forgets...the name..Enterprise, Picard
out."
>                                       Captain Picard - STNG

 
 
 

ls -l question

Post by test » Fri, 19 Dec 1997 04:00:00



> i want to use ls -l to get the date and time stamp off of a file, so i do
> a ls -l <filename> and pipe the output to awk and have it print the
> $6,$7,and the $8 fields. now my problem is that if the kilobytes field is
> greater than 1000000 then the $4th and $5th fields get merged and i have
> to print the $5th $6th and $7th field to get the same date and time stamp.
> is there anyway to get a date and timestamp of a file without ls -l so i
> don't have to worry about awk fields getting merged? any help will be
> greatly appreciated. thanks -maurice
>  --

[sig snipped]

Try this:

ls -o (FULL PATHNAME HERE) |tr -s [':space:']|cut -d' ' -f 5-8

And refer the the man pages for ls, tr, and cut for a complete
explantion.
--

The above opinions are mine, not my employer's.

 
 
 

ls -l question

Post by Brian McCaule » Fri, 19 Dec 1997 04:00:00



> i want to use ls -l to get the date and time stamp off of a file, so i do
> a ls -l <filename> and pipe the output to awk and have it print the
> $6,$7,and the $8 fields.

Why do you *want* to use ls?

Quote:> now my problem is that if the kilobytes field is
> greater than 1000000 then the $4th and $5th fields get merged and i have
> to print the $5th $6th and $7th field to get the same date and time stamp.
> is there anyway to get a date and timestamp of a file without ls -l so i
> don't have to worry about awk fields getting merged? any help will be
> greatly appreciated. thanks -maurice

Get the GNU varient of "find" and use -printf.

--

 .  _\\__[oo       from       | Phones: +44 121 471 3789 (home)

.  l___\\    /~~) /~~[  /   [ | PGP-fp: D7 03 2A 4B D8 3A 05 37...
 # ll  l\\  ~~~~ ~   ~ ~    ~ | http://wcl-l.bham.ac.uk/~bam/

 
 
 

ls -l question

Post by Eric Levene » Fri, 19 Dec 1997 04:00:00



 > Under bash or ksh, you can try:
 >
 > ls -l | awk '
 > {
 >     if ( length($4) > 6 )
 >         print $5$6$7
 >     else
 >         print $6$7$8
 > }
 >
 > With sh or csh, I believe you need to use \ and ;
 >
 > A better way may be to use cut:
 >
 > ls -l | cut -c42-44,45-47,48-53

All this depend of your local langage.
Do you try with non english ? :-)

--

--------------------------------------------------------------------
ric Lvnez              "Felix qui potuit rerum cognoscere causas"

(NeXTMail, MIME)                                   Georgica, II-489
--------------------------------------------------------------------