Sponsored Content
Full Discussion: wc -l
Top Forums Shell Programming and Scripting wc -l Post 302168880 by olenkline on Tuesday 19th of February 2008 04:38:50 PM
Old 02-19-2008
Split file wc -l

Here's a stab at it.

==========Script follows ===========
#!/bin/ksh
filename=$1
tline=$(wc -l $filename | awk '{print $1}')
let hline=$tline/2
split -l $hline $filename
=========== End of script ==========

This will output 2 files, call xaa and xab by default, check the man page for split to see how to make it what you want.

Syntax to execute it is scriptname [file_to_be_split]

Variable definitions
filename - file to be split
tline - number of lines in the file
hline - 1/2 of the number of lines in the file

Hope this helps, sure there are other ways.

Last edited by olenkline; 02-19-2008 at 05:52 PM.. Reason: Use of obsolete ` in Ksh script, and forgot a '
 
hline(3XCURSES) 					  X/Open Curses Library Functions					   hline(3XCURSES)

NAME
hline, mvhline, mvvline, mvwhline, mvwvline, vline, whline, wvline - use single-byte characters (and renditions) to draw lines SYNOPSIS
cc [ flag... ] file... -I /usr/xpg4/include -L /usr/xpg4/lib -R /usr/xpg4/lib -lcurses [ library... ] c89 [ flag... ] file... -lcurses [ library... ] #include <curses.h> int hline(chtype ch, int n); int mvhline(int y, int x, chtype ch, int n); int mvvline(int y, int x, chtype ch, int n); int mvwhline(WINDOW *win, int y, int x, chtype ch, int n); int mvwvline(WINDOW *win, int y, int x, chtype ch, int n); int vline(chtype ch, int n); int whline(WINDOW *win, chtype ch, int n); int wvline(WINDOW *win, chtype ch, int n); DESCRIPTION
The hline(), vline(), whline(), wvline() functions draw a horizontal or vertical line, in either the window stdscr or win starting at the current cursor position. The line is drawn using the character ch and is a maximum of n positions long, or as many as will fit into the window. If ch is 0 (zero), the default horizontal or vertical character is used. The mvhline(), mvvline(), mvwhline(), mvwvline() functions are similar to the previous group of functions but the line begins at cursor position specified by x and y. The functions with names ending with hline() draw horizontal lines proceeding towards the last column of the same line. The functions with names ending with vline() draw vertical lines proceeding towards the last column of the same line. These functions do not change the position of the cursor. PARAMETERS
ch Is the character used to draw the line. n Is the maximum number of characters in the line. y Is the y (row) coordinate for the start of the line. x Is the x (column) coordinate for the start of the line. win Is a pointer to a window. RETURN VALUES
On success, these functions return OK. Otherwise, they return ERR. ERRORS
None ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ |MT-Level |Unsafe | +-----------------------------+-----------------------------+ SEE ALSO
border(3XCURSES), border_set(3XCURSES), hline_set(3XCURSES), libcurses(3XCURSES), attributes(5), standards(5) SunOS 5.10 5 Jun 2002 hline(3XCURSES)
All times are GMT -4. The time now is 02:46 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy