find command to display size and date of a file

Hi,

The blow code does not yeild any output.

 find . -name "*.jar" -o -name "*.ksh" -o -name "*.properties" -name "*.war" -o -name "*.ear" -o -name "*.sh" -o -name "*.cfg" -exec ls -l {} \;

I wish to print the filename filesize filedate in HP-UX.

Can anyone help ?

try this

ls -lrt .jar* | awk '{print $9,$5,$6,$7,$8}

Here $9 is filesize, $5 is filesize and $6,7,8 is filedate

I need

find

command as I am checking under sub directories as well.

Instead of -exec ls -l {} \; try using -ls

Add below awk part...

I tried these but both of them failed.

 
==> find . -name "*.jar" -o -name "*.ksh" -o -name "*.properties" -name "*.war" -o -name "*.ear" -o -name "*.sh" -o -name "*.cfg" -ls
find: bad option -ls
shp051a1:/appl/bea/deployments>
==> find . -name "*.jar" -o -name "*.ksh" -o -name "*.properties" -name "*.war" -o -name "*.ear" -o -name "*.sh" -o -name "*.cfg" ls
find: missing conjunction

Perhaps try using brackets....

find . \( -name "*.jar" -o -name "*.ksh" -o -name "*.properties" -name "*.war" -o -name "*.ear" -o -name "*.sh" -o -name "*.cfg" \) -print | while read f; do ls -l "$f"; done

This works !!! but below is the output ...

-rw-r--r--   1 bea        users      49632210 May 19 15:51 ./hello.ear

Now, I need filename, File size and file date these three in this format.

Can you help ?

Just pipe the ls through the awk command as posted by NareshN

1 Like

Note that all of the find commands are missing a -o operator between -name "*.properties" and -name "*.war" . This causes the expression to be false when a file matches either pattern, excluding wanted files from the output.

Regards,
Alister