[SATLUG] Shell scripting challenge

Emon emon at lavabit.com
Mon Apr 6 15:05:37 CDT 2009


On 04/06/2009 09:58 PM, Enrique Sanchez Vela wrote:
>>>
>> rm -f xxf
>> lc=$(wc -l file| awk '{print $1}')
>> ((j=lc/5))
>> split -l $j file
>> if [ -f xxf ] ; then cat xxf >> xxe ; rm xxf; fi
>>
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 :-(

> 
> 
> this also works....
> 
> 
> lc=$(wc -l file| awk '{print $1}')
> ((j=lc/5))
> for i in 1 2 3 4
> do
> ((x=j*i))
> head -$x file | tail -$j >> file_$i
> done
> ((x=x+1))
> tail +$x file >> file_5
>

I can only say one word to appreciate the second script "FANTASTIC"

Although I must say I haven't yet read awk programming language, so I
did not understand the necessity of the line <awk '{print $1}')> can
someone please explain this to me :-)





More information about the SATLUG mailing list