Find command does not work on AIX 6.1

I have AiX system version 6.1

I wish the below find command to work on AiX system ksh shell and give similar output as this works fine on RedHat Linux centos 7.

find /app/logs/fname1.out -printf "%M %u %TY-%Tm-%Td %TH:%TM %h/%f $(cksum<fname1.out | cut -d' ' -f1)\n"

Output:

-rw-r--r-- root 2019-09-21 17:48 /app/logs/fname1.out 4294967295

I'm getting the below error on Aix system.

Can you please suggest ?

Looking at your line and what I know of find command, I would rather say find works as it should on AIX, and that your find does not look like a standard find command, why ? first find uses 2 argument to start with : 1 where to search, 2 what it is to find...
Not the case of your command line, then -print I doubt just like that with standard find...
My suggestion would be to go back to that centOS box and look what kind of find command you are dealing with, it could very well be an alias, or a script...

The find command works absolutely fine on CentOS and has no alias.

The find command was suggested by a forum Advisor @Chubler_XL here: Issues formatting output of two commands in a single line. Post: 303038249

Any solution that works for AiX will help ?

Many thanks.

Try the following

echo "$(find /app/logs/fname1.out -ls) $(cksum<fname1.out | cut -d' ' -f1)"

Too much information? Pipe the find output to cut and select the desired fields! (Like you do with the cksum output).

1 Like

But the challenge is that; it would not display the year of the recent files created today.

I need this information stored in the database so "year" is a must. Guess more tweaks required.

I believe perl is available on default AIX installations so this could be used to fetch the file modification time eg:

perl -e 'use POSIX qw(strftime);use File::stat; print strftime($ARGV[0], localtime(stat($ARGV[1])->mtime));' "%Y-%m-%d %H:%M" "/app/logs/fname1.out"
2 Likes

I will try this command today and reply to this thread in detail with my findings.

Or use the following script.

#!/usr/bin/perl
foreach $argfile (@ARGV) {
    ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
        $atime,$mtime,$ctime,$blksize,$blocks) = stat($argfile);
    ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($mtime);
    printf "%s-%02d-%02d %02d:%02d:%02d %s\n", 
        $year+1900, $mon+1, $mday, $hour, $min, $sec, $argfile;
}
echo "$(/path/to/script /app/logs/fname1.out) $(cksum<fname1.out | cut -d' ' -f1)"

Adapt it as you like.

1 Like
Moderator comments were removed during original forum migration.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.