The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




Thread: Help in unix
View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 05-16-2008
guest6 guest6 is offline
Registered User
  
 

Join Date: May 2008
Posts: 8
Help in unix

Hi,

I am a beginner in unix shell scripting. I wish to do the following things:

a) Read 3 new lines from a file (file2.txt) and appending them at the end of another file file1.txt.

I wrote the script as follows:

#! /bin/sh

set i = 0
set count =0
count = (wc -l file2.txt)
while(i -le $count)
do
i = i + 3;
head -i file2.txt >> file1.txt
done

I am getting an error in line "count = (wc -l file2.txt)". There is something wrong with my syntax because the script is not working. Please help.

Thanks

Last edited by guest6; 05-16-2008 at 04:31 PM..