Script to access multiple file and operate on single file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script to access multiple file and operate on single file
# 1  
Old 05-05-2017
Script to access multiple file and operate on single file

We have three files as mentioned below:
1. main_file.txt: This is the file in which all operations will be done. Which means this file will be signed by using the below two files
2. signature_file.txt: This is a status file and contains two signatures.
3. command.txt:file contains two commands which needs to be performed on main_file.txt as mentioned above.
main_file.txt looks like below:
Code:
 
 11,London,UK,Eurpoe,23
 13,Manchester,UK,Europe,21
 16,Florence, Italy, Europe, 212

signature_file.txt looks like below:

Code:
 
 C&8339334343221212134343434343223131324222242322
 D%343434343u3i4348t2233n2k4n24342131l#424342-323232



Command.txt file looks like below:

Code:
 
 Java <something something1>  main_file.txt
 Java <something something2>  main_file.txt



Now the script should do the following operation.

1. Insert a new line in the end of the main_file.txt
2. Pick the first signature (line 1) of the signature file and put it in the end of the main_file.txt
3. Insert a new line in the end of the main_file.txt
4. Pick the first command from the command.txt file and run it.
5. This command will generate a text output. Put that text output in the end of the main_file.txt.
6. Insert a new line in the end of the main_file.txt
7. Pick the second signature (line1) of the signature file and put it in the end of the main_file.txt
8. Insert a new line in the end of the main_file.txt
9. Pick the second command from the command.txt file and run it.
10. This command will generate a text output. Put that text output in the end of the main_file.txt. (No new line insertion after this point).

Can anybody help me in getting this sorted? I am at the loss as how to achieve this?

Thanks a ton.
# 2  
Old 05-05-2017
That sounds quite intangible. How would those text outputs look like, and how the final result. Does

1.
Insert a new line in the end of the main_file.txt
2. Pick the first signature (line 1) of the signature file and put it in the end of the main_file.txt

create an empty line before the signature?
# 3  
Old 05-05-2017
Quote:
Originally Posted by RudiC
That sounds quite intangible. How would those text outputs look like, and how the final result. Does

1.
Insert a new line in the end of the main_file.txt
2. Pick the first signature (line 1) of the signature file and put it in the end of the main_file.txt

create an empty line before the signature?
Hi Rudi,

Basically it only means that insert a first line of signature in the main_file.txt file. Actually I was thinking it loud to make it simple for myself.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Output file name and file contents of multiple files to a single file

I am trying to consolidate multiple information files (<hostname>.Linux.nfslist) into one file so that I can import it into Excel. I can get the file contents with cat *Linux.nfslist >> nfslist.txt. I need each line prefaced with the hostname. I am unsure how to do this. --- Post updated at... (5 Replies)
Discussion started by: Kentlee65
5 Replies

2. Shell Programming and Scripting

Tabbed multiple csv files into one single excel file with using shell script not perl

Hi Experts, I am querying backup status results for multiple databases and getting each and every database result in one csv file. so i need to combine all csv files in one excel file with separate tabs. I am not familiar with perl script so i am using shell script. Could anyone please... (4 Replies)
Discussion started by: ramakrk2
4 Replies

3. Shell Programming and Scripting

Multiple file and single parameter file

Hi Team, In our project we have written below 2 scripts like Script1: Shell script start & END Begin Audit process - uses teradata bteq END Audit Process Script 2: Environemtal variable file different Now Client ask to change this requirement and need below files: Script1:... (1 Reply)
Discussion started by: tusharzaware1
1 Replies

4. Shell Programming and Scripting

Execution of loop :Splitting a single file into multiple .dat file

hdr=$(cut -c1 $path$file|head -1)#extract header”H” trl=$(cut -c|path$file|tail -1)#extract trailer “T” SplitFile=$(cut -c 50-250 $path 1$newfile |sed'$/ *$//' head -1')# to trim white space and extract table name If; then # start loop if it is a header While read I #read file Do... (4 Replies)
Discussion started by: SwagatikaP1
4 Replies

5. Shell Programming and Scripting

Multiple File creation from Single file

I've one large file with below content TD: 0001 xxxx thnb .......... TD: 0001 yyyy abcd ......... ....... TD: 0002 xxyy efgh. ................... ................... TD: 0003 xxxx xyvx... (17 Replies)
Discussion started by: Steven77
17 Replies

6. Shell Programming and Scripting

Shell scripting - need to arrange the columns from multiple file into a single file

Hi friends please help me on below, i have 5 files like below file1 is x 10 y 20 z 15 file2 is x 100 z 245 file3 is y 78 z 23 file4 is x 100 (3 Replies)
Discussion started by: siva kumar
3 Replies

7. Shell Programming and Scripting

How to make multiple small file out of a single file?

Hi, I have a file that consist of around six million line, now the task is to divide this file into 12 small file so that each file would have half a million lines in it. Thanks. (3 Replies)
Discussion started by: mukulverma2408
3 Replies

8. Shell Programming and Scripting

Awk match multiple columns in multiple lines in single file

Hi, Input 7488 7389 chr1.fa chr1.fa 3546 9887 chr5.fa chr9.fa 7387 7898 chrX.fa chr3.fa 7488 7389 chr21.fa chr3.fa 7488 7389 chr1.fa chr1.fa 3546 9887 chr9.fa chr5.fa 7898 7387 chrX.fa chr3.fa Desired Output 7488 7389 chr1.fa chr1.fa 2 3546 9887 chr5.fa chr9.fa 2... (2 Replies)
Discussion started by: jacobs.smith
2 Replies

9. Shell Programming and Scripting

Script to multiple find and replace in a single file

Dear all I need a script for multiple find and replace in a single file. For example input file is - qwe wer ert rty tyu asd sdf dgf dfg fgh qwe wer det rtyyui jhkj ert asd asd dfgd now qwe should be replace with aaaaaa asd should be replace with bbbbbbbb rty should be replace... (6 Replies)
Discussion started by: wildhorse
6 Replies

10. Shell Programming and Scripting

Executing Multiple .SQL Files from Single Shell Script file

Hi, Please help me out. I have around 700 sql files to execute in a defined order, how can i do it from shell script (3 Replies)
Discussion started by: anushilrai
3 Replies
Login or Register to Ask a Question