[SATLUG] Shell scripting challenge

Enrique Sanchez Vela esanchezvela at yahoo.com
Tue Apr 7 15:37:56 CDT 2009



check the man page for the tail command on RH, it might not support the + option...


best regards,
esv.


--------------------------------------

Support the troops, bring them home.

http://therealnews.com/t/index.php?option=com_content&task=view&id=31&Itemid=74&jumival=2924


--- On Tue, 4/7/09, Emon <emon at lavabit.com> wrote:

> From: Emon <emon at lavabit.com>
> Subject: Re: [SATLUG] Shell scripting challenge
> To: "The San Antonio Linux User's Group Mailing List" <satlug at satlug.org>
> Date: Tuesday, April 7, 2009, 2:26 PM
> Hi again
> 
> I made some minor modifications to the script, it now looks
> like this
> 
> 
> *****************************************
> 
> #!/bin/bash
> 
> printf "Enter absolute file path "
> 
> read FILE
> 
> 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_Section_$i
> done
> 
> ((x=x+1))
> tail +$x $FILE >> File_Section_5
> 
> *****************************************
> 
> I have run this script on an file (also named "file") in my
> home
> directory which sixteen lines with the numbers one to
> sixteen typed at
> the beginning of each line; and it works just fine. I am
> running
> "openSUSE 11.1" fully updated.
> But when I ran this program on a "RHEL 5.2" machine on the
> same file, it
> produces five files but reported error
> 
> **************
> tail: cannot open `+13' for reading: No such file or
> directory
> **************
> 
> When I checked the output of the 5th file (File_Section_5);
> it looked
> like this
> 
> *********************
> ==> /home/student/file <==
> 7
> 8
> 9
> 10
> 11
> 12
> 13
> 14
> 15
> 16
> *********************
> 
> So, have I made any mistake in the script or is there
> something else
> that I over looked???
> 
> Emon
> 
> 
> -- 
> _______________________________________________
> SATLUG mailing list
> SATLUG at satlug.org
> http://alamo.satlug.org/mailman/listinfo/satlug to
> unsubscribe
> Powered by Rackspace (www.rackspace.com)
> 


      


More information about the SATLUG mailing list