- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Need help with scripts to save contents of logfile...
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-02-2004 10:08 PM
08-02-2004 10:08 PM
I want to be able to save the textual output of Script1 to a file for every 1000 lines whereas the first 1000 line output is save to file1 and the next 1000 lines out is save to file2 and so on.
I want to achive this without saving the output of Script1 to a file first and later on be processed by another script.
Can this be achieved with awk or sed? Can someone please start me off or point me in the right direction by providing a sample script that will do the task.
Thanks in advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2004 10:50 PM
08-02-2004 10:50 PM
SolutionUse
split(1) split(1)
NAME
split - split a file into pieces
SYNOPSIS
split [-l line_count] [-a suffix_length] [file [name]]
split [-b n[k|m]] [-a suffix_length] [file [name]]
Obsolescent
split [-n] [file [name]]
DESCRIPTION
split reads file and writes it in pieces (default 1000 lines) onto a
set of output files. The name of the first output file is name with
aa appended, and so on lexicographically, up to zz (only ASCII letters
are used, a maximum of 676 files). If no output name is given, x is
the default.
Steve Steel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2004 10:51 PM
08-02-2004 10:51 PM
Re: Need help with scripts to save contents of logfiles
can do the job.
sks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2004 11:09 PM
08-02-2004 11:09 PM
Re: Need help with scripts to save contents of logfiles
your_script | split -l 1000
If you want to specify filenames for your output, rather than getting the default xaa, xab etc
use
your_script | split -l 1000 - file_prefix
(note the - to indicate use of standard input as the input file name). The file prefix can be anything you like, for example, if you put the prefix as "logfile", you'd get files of logfileaa, logfileab etc.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2004 11:48 PM
08-02-2004 11:48 PM
Re: Need help with scripts to save contents of logfiles
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2004 11:54 PM
08-02-2004 11:54 PM
Re: Need help with scripts to save contents of logfiles
split -l 10 big Kenneth
And following files will be created:
Kennethaa Kennethad Kennethag Kennethaj
Kennethab Kennethae Kennethah Kennethak
Kennethac Kennethaf Kennethai Kennethal
(big has 112 lines)
sks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2004 11:54 PM
08-02-2004 11:54 PM
Re: Need help with scripts to save contents of logfiles
split -l 10 big Kenneth
And following files will be created:
Kennethaa Kennethad Kennethag Kennethaj
Kennethab Kennethae Kennethah Kennethak
Kennethac Kennethaf Kennethai Kennethal
(big has 112 lines)
sks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2004 12:14 AM
08-03-2004 12:14 AM
Re: Need help with scripts to save contents of logfiles
your_tool | perl -ne 'if (!($i++%1000)){$x=sprintf(">test_%03d",$n++); open(X,$x)} print X'
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2004 02:28 AM
08-03-2004 02:28 AM