title: extracting the first 10KB chunk from a text file and then moving the new file to a different location
body: <p>I have all the text files at bigdata/*.txt.The format of this file is languageName-xxx-10MB.txt. I want to perform an operation that would chunk these files from 10MB to the first 10KB recursively and then place the newly formed file at ../smalldata/.The newly formed file should be in the format of languageName-xxx-10KB.txt</p>
  
  <p>I have tried both the operations independently.The first being looping over all the files in the bigdata/ using</p>
  
  <pre><code>#!/bin/bash
  for entry in bigdata/*
  do
  echo "$entry"
  done
  </code></pre>
  
  <p>I get the output as</p>
  
  <pre><code>bigdata/lang1-xxx-10MB.txt
  bigdata/lang2-xxx-10MB.txt
  .
  .
  bigdata/langn-xxx-10MB.txt
  </code></pre>
  
  <p>I have also tried using the <code>head</code> command that gets me the first 10KB of the files using</p>
  
  <pre><code>head -c 10240 lang1-xxx-10MB.txt &gt; ../smalldata/lang1-xxx-10KB.txt
  </code></pre>
  
  <p>I am looking for a way to merge this two tasks iteratively.</p>