Help on writing scripts!!??


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help on writing scripts!!??
# 1  
Old 03-03-2003
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
# 2  
Old 03-03-2003
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.
Code:
#! /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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Writing Hbase and pig scripts in the bash script file

Hi, I have a script file where i'm validatig the input file and storing the validated records on HDFS. I wanted to load data from HDFS to HBASE using pig script. So for that i have created a HBASE table and written pig script to load data from HDFS to HBASE which is working fine. Now i wanted... (0 Replies)
Discussion started by: shree11
0 Replies

2. Shell Programming and Scripting

Writing hive scripts in bash script file

Hi, I wanted to load data from HDFS to HIVE by writing bash script. Description: I have written a bash script to validate the data and loaded validated data from local file system to HDFS. Now in the same bash script i wanted to load the data from HDFS to HIVE. How can i do it ? Also how tyhe... (2 Replies)
Discussion started by: shree11
2 Replies

3. What is on Your Mind?

Stop Writing Scripts

Please, I beg you, “Stop!” Yes, stop writing scripts and instead build workflows. Programmers, Sys-Admins, System Support, I'm talking to you. Ok, I know in this community I'm going to get some serious backlash for my statements but I truly believe in my statement. There was a time when... (13 Replies)
Discussion started by: mikemazz
13 Replies

4. Shell Programming and Scripting

Writing Bash shell scripts corresponding to windows bat files

Experts, I am newbie in shell scripting. I want to write Bash shell scripts corresponding to windows bat files. I have installed cygwin at c:\cygwin and i am trying to crate the sh file using vi editor. i am not able to understand how to use linux/unix convention for the code. following is my... (15 Replies)
Discussion started by: rajuchacha007
15 Replies

5. Shell Programming and Scripting

writing shell scripts of commands

can anyone help me in writing a shell script to visualize how simple commands work and on what logic. For Eg: ls command how it lists out all the files and directories, need to write a simple script based on the commands source code.:D (0 Replies)
Discussion started by: rahul_11d
0 Replies

6. AIX

Examples of writing shell scripts for AIX, it's urgent

Please help me 1. Please give me the few examples of shell scripts written for AIX 2.I have scripts written on Unix, does that work for AIX, if not what are the changes to be carried out to run the scripts on AIX.... Please help me (4 Replies)
Discussion started by: me_haroon
4 Replies

7. Shell Programming and Scripting

writing scripts

What would happen if I didn't use "./" before writing a script? (4 Replies)
Discussion started by: ebethea27703
4 Replies

8. Shell Programming and Scripting

Is writing shell scripts different than...

I am currently taking a linux shell scripting class and also a intro to programming class using QBASIC. Will this interfere with how i learn each one? Are they similar in some ways? I already took a unix course based on the commands and it was easy, but now i have to create programs. Also, how... (1 Reply)
Discussion started by: brentdeback
1 Replies

9. Shell Programming and Scripting

writing schell scripts

I am very new to Unix. I need to write a script that will grep some files, etc. When I write the script, do I need to know what shell I am using? If so, how do I do that? (1 Reply)
Discussion started by: ssmiths001
1 Replies

10. UNIX for Dummies Questions & Answers

help for newbie writing shell scripts

Hi, I have just started a Systems Programming course and am required to write a c shell script as part of it. I have little to no clue about unix. The spec states that the script can be run only once on each host by a user, but the script can be run on different hosts by the one user. ... (2 Replies)
Discussion started by: richgi
2 Replies
Login or Register to Ask a Question