![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| help splitting a file into multiple files in bash | elinenbe | Shell Programming and Scripting | 2 | 04-30-2009 12:37 PM |
| splitting the large file into smaller files | vsnreddy | UNIX for Dummies Questions & Answers | 1 | 11-16-2008 09:09 PM |
| Splitting text file to several other files using sed. | JeffV | Shell Programming and Scripting | 3 | 03-14-2008 03:34 PM |
| splitting files based on text in the file | matrix1067 | Shell Programming and Scripting | 1 | 01-30-2006 08:45 PM |
| Splitting large file into small files | dncs | Shell Programming and Scripting | 4 | 06-08-2005 12:02 PM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Hi,
I have an input file like: Code:
111 abcdefgh asdfghjk dfghjkl 222 aaaaaaa bbbbbb 333 djfhfgjktitjhgfkg 444 djdhfjkhfjkghjkfg hsbfjksdbhjkgherjklg fjkhfjklsahjgh fkrjkgnj I have created the following script but its not helping.. Code:
#!/usr/bin/ksh
set -x
linecount=`cat testfile|wc -l`
numval=`cat testfile|grep ^[0-9]|wc -l`
i=0
set -A arr `awk '/[0-9]/{print NR}' testfile`
while [ $linecount -gt 0 ]
do
while [ $i -le $numval ]
do
val=`echo ${arr[i]}`
cat testfile|head -${val} > file${i}
i=`expr $i + 1`
done
linecount=`expr $linecount - 1`
done
Last edited by Franklin52; 4 Weeks Ago at 06:56 AM.. Reason: Please use code tags! |
| Bookmarks |
| Tags |
| split, splitting file |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|