Find command does not work on AIX 6.1


Login or Register for Dates, Times and to Reply

 
Thread Tools Search this Thread
# 1  
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.

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

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

I'm getting the below error on Aix system.

Quote:
find: bad option -printf
Can you please suggest ?
# 2  
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...
# 3  
The find command works absolutely fine on CentOS and has no alias.

The find command was suggested by a forum Advisor @Chubler_XL here: https://www.unix.com/303038249-post4.html

Any solution that works for AiX will help ?

Many thanks.
# 4  
Try the following
Code:
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).
This User Gave Thanks to MadeInGermany For This Post:
# 5  
Quote:
Originally Posted by MadeInGermany
Try the following
Code:
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).
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.
# 6  
I believe perl is available on default AIX installations so this could be used to fetch the file modification time eg:

Code:
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"

These 2 Users Gave Thanks to Chubler_XL For This Post:
# 7  
Quote:
Originally Posted by Chubler_XL
I believe perl is available on default AIX installations so this could be used to fetch the file modification time eg:

Code:
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"

I will try this command today and reply to this thread in detail with my findings.
Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #711
Difficulty: Easy
The earliest computing machines had fixed programs.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Prune Option for Find Command on AIX

I need to delete all files from the working directory and its sub directories using the find command, for that I am using -prune option but some how I am having a syntax issue. I have tried the below, please help me correct the syntax find . -name \* -type f -exec rm -f {} \; >> Works but... (4 Replies)
Discussion started by: rosebud123
4 Replies

2. AIX

AIX - find command with mtime

Hello experts, I would get from a list of files, which are more ancient than 1 hour. Examples: Current date: Wed Oct 28 16:10:02 SAT 2015 using: find path -name 'file_name. *' -mtime +0 I see files with less at 00:00:00 date of the current day. /path/file_name.20151027170725... (7 Replies)
Discussion started by: carlino70
7 Replies

3. Shell Programming and Scripting

Find command not working on AIX

Hello, I am running find command in an AIX Server to find last 7 days modified directories/files. >cd /usr/openv/netbackup/db/class >ls -l total 0 drwxr-xr-x 3 root system 256 May 28 2014 Catalog-Backup drwxr-xr-x 3 root system 256 Sep 18 2012 ... (4 Replies)
Discussion started by: rahul2662
4 Replies

4. AIX

AIX: How to find down who enter a command?

Hi I'm working on AIX. My question: for example, I'm logging in. I enter command "last" and then I know there are 3 people logging in from 3 different IP at the same time, 2 are in the same account. Then someone enters a command. Is there any way to know exactly who ( which IP ) enters... (9 Replies)
Discussion started by: bobochacha29
9 Replies

5. UNIX for Dummies Questions & Answers

find command in shell script doesn't work

Hello all, Something strange going on with a shell script I'm writing. It's trying to write a list of files that it finds in a given directory to another file. But I also have a skip list so matching files that are in that skip list should be, well uhm, skipped :) Here's the code of my... (2 Replies)
Discussion started by: StijnV
2 Replies

6. UNIX for Dummies Questions & Answers

find command AIX

Hi all , could anyone please help with find command in AIX. I am trying to find files but there are more than 30thousand files in there.I realise I need to use xargs somehow but dunno the correct way to pull this. find /log_directory/* -prune -xdev -type f -mtime +20 | xargs ls -l the... (2 Replies)
Discussion started by: erinlomo
2 Replies

7. UNIX for Dummies Questions & Answers

find command returns files with spaces, mv won't work...

Hi guys. I am trying, to move files found with the find command... Script runs fine, until it reaches a file that contains spaces... Here is what i wrote up quickly. ROOTDIR=/apps/data SEARCH=$(find /data/HDTMPRestore/home/tmq/ -type f -print | grep Mods/Input/bck | cut -c19-) for i... (1 Reply)
Discussion started by: Stephan
1 Replies

8. Shell Programming and Scripting

find command with exec doesnt work

Hi There, I have a script which finds for log files and removes them if the file has changed in the last day. The script runs fine without errors. The log file is still there. So, I decided to print the find command and run the command outside the script. Getting "Incomplete statement" Can you... (6 Replies)
Discussion started by: funtochat2002
6 Replies

9. AIX

does find command always work ?!

hello ! can so help me ? here is my problem : a same command, using find command works on a server, but doesn't on another. I've been told, that it could be because of the file systems ... it's amazing ! can so explain, please ? thank you for your answer (1 Reply)
Discussion started by: chocolate
1 Replies

10. UNIX for Dummies Questions & Answers

Use -prune with find command on AIX

I am trying to get a list of top level directories below the search path but I don't want to descend subdirectories. The find command listed below returns me the list I want but it also returns subdirectories. I can't seem to get the -prune option to work the way I want. How would I modify the... (5 Replies)
Discussion started by: FuzzySlippers
5 Replies

Featured Tech Videos