Help on writing scripts!!??

Hello,

I don't know anything about scripting, and I want help on writing a script, which can help me doing my research.
Actually I have some ASCII format files formatted in a way looks like this

6 lines of text that is not important for me
File_header_name_number_1 <-- Important file for me let's call it file X
68 lines not important.
File_header_name_number_2
68 lines not important.
File_header_name_number_3
68 lines not important.

Then some footer, which is different in number between the files.

Some information before I start to explain

  • All the files have same structure and number of lines, which is not needed between the X file names.

  • No all files contain same X files. Some of them 1 and some 2 and some 3 .........

  • Last file format which I'm planning to get out of the script looks like this

File_header_name_number_1
File_header_name_number_2
File_header_name_number_3

What I'm doing now is open the ASCII file with vi editor to get similar output (MANUALLY)

Vi filename.txt
�D6d > j > d68d > j > d68d > j > d68d� and soo on till I reach to the pint where I will have some lines after the last file I want X so if I keep on continue after the last file and I typed d68d I will get beeeb coz the files less than 68 lines after the last X file.

I don't know if I was clear enough, but any further explanation that give you clear picture feel free to ask.

Regard,
Karim

If I understand, you have a bunch of ascii file with at least 145 lines of text in them. From each file you want only lines 7, 76, and 145.

#! /usr/bin/ksh
for file ; do
     sed -n '7p;76p;145p' < $file
done
exit 0

Just run that script with the file names as arguments to it.