HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Script with awk
Operating System - HP-UX
1834276
Members
2522
Online
110066
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2004 05:50 PM
01-20-2004 05:50 PM
Script with awk
I have list file,I want to now if 1 file on a directory was change size or date time, I get the email for this case. If the file not modified the date time or size, email not come.
Rommy Setiadi
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2004 06:03 PM
01-20-2004 06:03 PM
Re: Script with awk
For this, you need to keep record of the last time the check command ran.
This doesn't seem like an awk script. Just from shell is good enough, I think:
#!/bin/ksh
if [ $# -ne 1 ]
then
echo "Usage: $0"
exit 1
fi
BASE=`basename "$1"`
STAMPFILE="/var/adm/stamps/${BASE}.stamp"
if [ -f $"{STAMPFILE}" ]
then
mv "${STAMPFILE}" "${STAMPFILE}.prev"
fi
ls -l "$1" >"${STAMPFILE}"
if [ -f "${STAMPFILE}.prev" ]
then
if cmp -s "${STAMPFILE}" "${STAMPFILE}.prev"
then
echo "Files are the same"
else
echo "File changed."
echo "Was:"
cat "${STAMPFILE}.prev"
echo "Is now:"
cat "${STAMPFILE}"
fi
else
echo "First run. Nothing to compare yet."
fi
This doesn't seem like an awk script. Just from shell is good enough, I think:
#!/bin/ksh
if [ $# -ne 1 ]
then
echo "Usage: $0
exit 1
fi
BASE=`basename "$1"`
STAMPFILE="/var/adm/stamps/${BASE}.stamp"
if [ -f $"{STAMPFILE}" ]
then
mv "${STAMPFILE}" "${STAMPFILE}.prev"
fi
ls -l "$1" >"${STAMPFILE}"
if [ -f "${STAMPFILE}.prev" ]
then
if cmp -s "${STAMPFILE}" "${STAMPFILE}.prev"
then
echo "Files are the same"
else
echo "File changed."
echo "Was:"
cat "${STAMPFILE}.prev"
echo "Is now:"
cat "${STAMPFILE}"
fi
else
echo "First run. Nothing to compare yet."
fi
Every problem has at least one solution. Only some solutions are harder to find.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2004 06:21 PM
01-20-2004 06:21 PM
Re: Script with awk
Why using awk to find changed files, you can use find to find changed files within the last 24hours.
find /path/directory -mtime 1 >/tmp/tmp.lst
if [ `cat /tmp/tmp.lst | wc -l` -gt 0 ]
then
cat /tmp/tmp.lst | mailx -s "files found" account@domain.com
fi
find /path/directory -mtime 1 >/tmp/tmp.lst
if [ `cat /tmp/tmp.lst | wc -l` -gt 0 ]
then
cat /tmp/tmp.lst | mailx -s "files found" account@domain.com
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2004 12:34 AM
01-21-2004 12:34 AM
Re: Script with awk
Another approach:
Store the output of 'ls -l'.
Net time you run 'ls -l' again, and run a diff between the two listings.
This will only tell you 'something' has changed.
If you want to keep history, use rcs to store all (different) versions.
JP
Store the output of 'ls -l'.
Net time you run 'ls -l' again, and run a diff between the two listings.
This will only tell you 'something' has changed.
If you want to keep history, use rcs to store all (different) versions.
JP
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP