HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: calculations in a korn script
Operating System - HP-UX
1830939
Members
2764
Online
110017
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
Go to solution
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-30-2001 03:13 PM
01-30-2001 03:13 PM
i'm gonna start hacking away here, but if someone can help me cut to the chase, that would be great. i have to put a script together that can split a file into two halves. for example, if a file contains 127 records, i'd like to run the head and tail commands against the file: head 64 file1 >/tmp/foo ... tail 63 file1 >/tmp/foo1. can i generate the values 64 and 63 perhaps using the "wc" utility and then doing some division and subtraction? can calculations like this be done in a korn script?
thank you all in advance. i know you'll come through again:-)
thank you all in advance. i know you'll come through again:-)
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2001 03:38 PM
01-30-2001 03:38 PM
Solution
Hi,
Yes, you can do calculations in ksh.
-----
lines=$(wc -l /your/file)
(( half = lines / 2 ))
echo $half
-----
Only integer calculations are possible.
If you want to split a file into pieces, you should check out the split(1) command.
Hope this helps,
Rik.
Yes, you can do calculations in ksh.
-----
lines=$(wc -l /your/file)
(( half = lines / 2 ))
echo $half
-----
Only integer calculations are possible.
If you want to split a file into pieces, you should check out the split(1) command.
Hope this helps,
Rik.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2001 04:05 PM
01-30-2001 04:05 PM
Re: calculations in a korn script
rik,
good job. that's just what i needed!! THANKS FOR YOUR HELP:-)
good job. that's just what i needed!! THANKS FOR YOUR HELP:-)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2001 04:14 PM
01-30-2001 04:14 PM
Re: calculations in a korn script
Hi:
While the shell only allows integer arithmetic, real arithmetic can be done with the 'bc' or 'awk' utilities. See this thread for a recent series of examples.
http://forums.itrc.hp.com/cm/QuestionAnswer/1,1150,0x6bc679bffde7d4118fef0090279cd0f9,00.html
...JRF...
While the shell only allows integer arithmetic, real arithmetic can be done with the 'bc' or 'awk' utilities. See this thread for a recent series of examples.
http://forums.itrc.hp.com/cm/QuestionAnswer/1,1150,0x6bc679bffde7d4118fef0090279cd0f9,00.html
...JRF...
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