[SATLUG] Shell scripting challenge

Emon emon at lavabit.com
Tue Apr 7 03:55:07 CDT 2009

On 04/07/2009 02:37 AM, Enrique Sanchez Vela wrote:
>> What does this <if [ -f xxf ]> line mean?? I am sorry
>> for asking this,
>> cos I know I mentioned that I have some basic knowledge of
>> bash & c++
>> but I am just realizing that they are hopelessly inadequate
>> :-(
> the <if [ -f xxf ] > line means that if the file with name xxf exists, then 
>  append the contents of the sixth file into the 5th.
> the split command splits the files using -l <LINES> each, so it will create 5 files of $j lines and one more with the reminding ones, that is why I test whether the file exists or not, if it exists, then append the output to the 5th file.
> somehow the command I originally sent is flawed, the correct script is...
>  rm -f xaf
>  lc=$(wc -l file| awk '{print $1}')
>  ((j=lc/5))
>  split -l $j file
>  if [ -f xaf ] ; then cat xaf >> xae ; rm -f xaf; fi
> the awk '{print $1 }' ; does split the input line and print only the first field ignoring spaces.
> best regards,
> esv.

Thanks Enrique.... you have been a great teacher :-)

I wish I could give more just a "thanks"; but that all I have right now

So once again, Thank you very much


More information about the SATLUG mailing list