Hi
I have a 57 line text file and I want to cut first 6 line assigned it to a veriable and again cut next 6 line assigned to same variable till the time file have left 0 line.
Please let me know how I can do in scripting.
Thanks
Sanjay
Hi
I have a 57 line text file and I want to cut first 6 line assigned it to a veriable and again cut next 6 line assigned to same variable till the time file have left 0 line.
Please let me know how I can do in scripting.
Thanks
Sanjay
We want to help you if you have shown that you have put some effort into solving your own problem but not to do your work for you.
hi
my original file /var/tmp/img-bkp1
head -6 /var/tmp/img-bkp1 >/var/tmp/used
grep -v -f /var/tmp/used /var/tmp/img-bkp1 >/var/tmp/unused.1
head -6 /var/tmp/unused.1 >/var/tmp/used
grep -v -f /var/tmp/used /var/tmp/unused.1 >/var/tmp/unused.2
head -6 /var/tmp/unused.2 > /var/tmp/used
grep -v -f /var/tmp/used /var/tmp/unused.2 >/var/tmp/unused.3
and so on
can you please tell me how put in loop so that file have left 0 line
try this..
for i in 1 7 13 19 25 31 37 43 49 55
do
plus_six=`echo $i + 6 | bc`
sed '"$i","$plus_six"p' filename >/var/tmp/output$i.txt
done
use split command to split the file
split -l 6 /var/tmp/img-bkp1
this will create the xx* file names in the same directory
you can read each one like
for i in xx*
do
---
done
Please refer to man pages on split also
try this..
% split -6 input_file; ls -1 x* | awk ' { print $0"_1=`cat "$0"`;" } ' | sh
Could you please tell us more about your final goal ?
a) How does the content of you input file look like ?
b) Why do you need lines 6 per 6 ?
c) What kind of processing do you run on them ?
d) What kind of output do you expect ?