- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Help in Scripting.
Operating System - HP-UX
1824945
Members
3868
Online
109678
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
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
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
тАО07-26-2010 09:29 PM
тАО07-26-2010 09:29 PM
Help in Scripting.
Hi,
I am very new to scripting.I need to develop one script that suit the following condition.
1. Intially i have two files test.log and newtest.log (contents are same).
2. The first file (test.log)will be keep on updating.
3. I need to take the difference (no of new lines added )and copy the new lines to another log file (say final.log).
4. Copy the test.log to newtest.log.
5. In the file one if a text is matching for say 4 or 5 times i need to add a new line in another log file.
Any suggestion or help will be appreciated.
Thanks in advance..
I am very new to scripting.I need to develop one script that suit the following condition.
1. Intially i have two files test.log and newtest.log (contents are same).
2. The first file (test.log)will be keep on updating.
3. I need to take the difference (no of new lines added )and copy the new lines to another log file (say final.log).
4. Copy the test.log to newtest.log.
5. In the file one if a text is matching for say 4 or 5 times i need to add a new line in another log file.
Any suggestion or help will be appreciated.
Thanks in advance..
- Tags:
- scripting
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-27-2010 01:38 AM
тАО07-27-2010 01:38 AM
Re: Help in Scripting.
Are the files sorted? If so you can use comm(1):
comm -23 test.log newtest.log > final.log
4) cp test.log newtest.log
5)
if [ ! -s final.log ]; then
if [ ! -f count.log ]; then
echo "5" > count.log
fi
match_count=$(< count.log)
(( match_count -= 1 ))
if [ $match_count -lt 0 ]; then
echo "No changes in 5 compares" >> another_log_file
match_count=5
fi
echo "$match_count" > count.log
fi
comm -23 test.log newtest.log > final.log
4) cp test.log newtest.log
5)
if [ ! -s final.log ]; then
if [ ! -f count.log ]; then
echo "5" > count.log
fi
match_count=$(< count.log)
(( match_count -= 1 ))
if [ $match_count -lt 0 ]; then
echo "No changes in 5 compares" >> another_log_file
match_count=5
fi
echo "$match_count" > count.log
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-27-2010 08:29 AM
тАО07-27-2010 08:29 AM
Re: Help in Scripting.
The 1-4 steps can be done using the following script. This will compare the files every 10 sec and send the difference to final.log
touch final.log
while true;do
diff test.log newtest.log >> final.log
cp test.log newtest.log
sleep 10
done
I am not clear the step 5, can you elaborate?
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
Learn About
News and Events
Support
© Copyright 2025 Hewlett Packard Enterprise Development LP