- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Random sampling from a file
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
Discussions
Discussions
Forums
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
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
тАО02-27-2001 03:01 PM
тАО02-27-2001 03:01 PM
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-27-2001 03:27 PM
тАО02-27-2001 03:27 PM
Re: Random sampling from a file
hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-27-2001 03:31 PM
тАО02-27-2001 03:31 PM
Re: Random sampling from a file
to this scripting thing, so may I indulge your patience?
How would I code the head
statement? Thanks...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-27-2001 03:47 PM
тАО02-27-2001 03:47 PM
Re: Random sampling from a file
#!/usr/bin/ksh
file="/path/filename" # Your data file
Number=`echo "($RANDOM)" |bc` # This is first random number
OtherNumber=`echo "($RANDOM)" |bc` # This is second random number
#Now test which number is bigger
if [ $Number -gt $Othernumber ];
then
cat $filename | tail $Number | Head $othername
else
cat $filename | tail $othername |head $Number
fi
So for example ( say your data file has 500 lines altogether) if the first number is 400 and second is 300 , the program will show you the lines starting from 100 to 400 .
Hope this is clear.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-27-2001 03:49 PM
тАО02-27-2001 03:49 PM
Re: Random sampling from a file
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-27-2001 03:56 PM
тАО02-27-2001 03:56 PM
Re: Random sampling from a file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-27-2001 04:00 PM
тАО02-27-2001 04:00 PM
SolutionFor another example say this is your file:
test line1
test line2
test line3
test line4
test line5
Then it will grab something like this :
test line2
test line3
etc.etc.
Hope this helps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-27-2001 04:03 PM
тАО02-27-2001 04:03 PM
Re: Random sampling from a file
Cathy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-27-2001 04:27 PM
тАО02-27-2001 04:27 PM
Re: Random sampling from a file
minus in front of the $Number and $Othernumber in the head/tail references. Otherwise it treats it as a filename.
I think. ;-)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-27-2001 05:03 PM
тАО02-27-2001 05:03 PM