The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #6 (permalink)  
Old 09-30-2008
joeyg's Avatar
joeyg joeyg is offline Forum Staff  
modérateur
  
 

Join Date: Dec 2007
Location: Home of 17-time world champion Boston Celtics
Posts: 1,311
Wink what about this?


Code:
> cat -n big_file4 | awk '{printf "%1s %-100s \n", substr($1,length($1),1), $0}' | cut -c1,10- | grep "^[147]" | cut -c2- >filea
> cat -n big_file4 | awk '{printf "%1s %-100s \n", substr($1,length($1),1), $0}' | cut -c1,10- | grep "^[258]" | cut -c2- >fileb
> cat -n big_file4 | awk '{printf "%1s %-100s \n", substr($1,length($1),1), $0}' | cut -c1,10- | grep "^[369]" | cut -c2- >filec
> cat -n big_file4 | awk '{printf "%1s %-100s \n", substr($1,length($1),1), $0}' | cut -c1,10- | grep "^[0]" | cut -c2- >filed


Code:
> cat big_file4
a stuff to 1 file
b stuff to 2 file
c stuff to 3 file
a stuff to 1 file
b stuff to 2 file
c stuff to 3 file
a stuff to 1 file
b stuff to 2 file
c stuff to 3 file
d stuff to 4 file
a stuff to 1 file
b stuff to 2 file
c stuff to 3 file
a stuff to 1 file
b stuff to 2 file
c stuff to 3 file
a stuff to 1 file
b stuff to 2 file
c stuff to 3 file
d stuff to 4 file

and now the four separated files

Code:
> cat filea
a stuff to 1 file                                                                             
a stuff to 1 file                                                                             
a stuff to 1 file                                                                             
a stuff to 1 file                                                                             
a stuff to 1 file                                                                             
a stuff to 1 file                                                                             
> cat fileb
b stuff to 2 file                                                                             
b stuff to 2 file                                                                             
b stuff to 2 file                                                                             
b stuff to 2 file                                                                             
b stuff to 2 file                                                                             
b stuff to 2 file                                                                             
> cat filec
c stuff to 3 file                                                                             
c stuff to 3 file                                                                             
c stuff to 3 file                                                                             
c stuff to 3 file                                                                             
c stuff to 3 file                                                                             
c stuff to 3 file                                                                             
> cat filed
d stuff to 4 file                                                                             
d stuff to 4 file                                                                             
>