- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- variable definition in posix shel.l
Categories
Company
Local Language
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
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
Community
Resources
Forums
Blogs
- 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
08-12-2003 08:12 PM
08-12-2003 08:12 PM
do
let F_SUM=$F_SIZE+$F_SUM
echo $F_SUM
done
echo $F_SUM
**************************************
The above shell is the sum of the files's size listed in the fbackup_cold_backup.log.
F_SUM is the type of integer.
I need to define the type of float.
How do I do?
Thanks for your answer in advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2003 08:23 PM
08-12-2003 08:23 PM
Re: variable definition in posix shel.l
I'm not sure if it is possible to define a float in the shell.
You can define an integer using the typeset command. Refer to the sh-posix man page for further details. It might provide other options which will give what you are after.
Hope it helps.
Tim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2003 08:35 PM
08-12-2003 08:35 PM
Solution/usr/dt/bin/dtksh does though. and of course shells newer then 11/88.
using dtksh or ksh93, etc. the syntax would be typeset -E for floating point, scientific notation and typeset -F for floating point, fixed precision. and usually there is a preset alias "float" to declare floating point variables.
float var1
typeset -E var2
etc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2003 08:36 PM
08-12-2003 08:36 PM
Re: variable definition in posix shel.l
I found a posix manual..
the 'typeset' command haven't the type of float.
Is there any solution to define the float type?
Thanks for your answer in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2003 08:43 PM
08-12-2003 08:43 PM
Re: variable definition in posix shel.l
cat /var/adm/cron_src/fbackup_cold_backup.log |
awk '{
sum += $1;
printf("%f\n",$1);
} END {
printf("%f\n",sum);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2003 09:06 PM
08-12-2003 09:06 PM
Re: variable definition in posix shel.l
#!/usr/dt/bin/dtksh
float F_SUM
cat /var/adm/cron_src/fbackup_cold_backup.log |
while read F_SIZE rest
do
F_SUM=$(($F_SIZE + $F_SUM))
printf "%d\n" $F_SUM
done
printf "%d\n" $F_SUM