Form a pipeline script with series of steps


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Form a pipeline script with series of steps
# 1  
Old 01-08-2015
Form a pipeline script with series of steps

Hello all,

This maybe a dumb question,

I have a series of awk command liners, perl and C executables that I usually run in a particular order to get an output. I need 2 files as input and then , a series of outputs are produced which pipe into the next step etc.

I am usually able to paste all these steps serially into command line terminal and get my desired output...Can I safely integrate all these steps into a bash script and run that with arguments as my two input filenames and output filename?

Example of paste into terminal pipeline

Code:
#Step 1 

awk '...' infile1 infile2 > tmp

# Step 2

awk '...'  infile2 tmp > tmp2


...

# Step 5

perl '....' > tmp5
... 

# Step 12 (Final step)

awk '.....' tmp45 > final_output

# 2  
Old 01-08-2015
Yes you can integrate them smoothly,
Code:
./script.sh input_file1 input_file2 output_file

Then you can have your script like:
Code:
awk '..' $1 $2 > tmp //$1 is input_file1 and $2 is input_file2 

awk '...' $2 tmp > tmp2

....

awk '...' tmp45 > $3 // $3 output_file which is 3rd argument

This User Gave Thanks to penqueen For This Post:
# 3  
Old 01-08-2015
In general anything you do at the command line you can script.

This is a bit confusing and seemingly inefficient namely because you are using a great number of files and using files more than once. Can these one liner awk scripts be combined?

For example, you awk infile2 twice. The first time it is used to create file tmp. The second time you do it it is awked with a file (tmp) that it was used to create.

The answer to your question in general is yes you can script it, but why is there a need to use all these files.
This User Gave Thanks to blackrageous For This Post:
# 4  
Old 01-08-2015
Quote:
Originally Posted by blackrageous
.

The answer to your question in general is yes you can script it, but why is there a need to use all these files.
I need all the intermediate steps because, the intermediate files go into different pipelines once produced, you are right,some of the awk scripts can be combined and made more streamlined..
This User Gave Thanks to senhia83 For This Post:
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Should pick latest file within past 3 days using UNIX script and perform steps in message below.

Hi , Can anyone help me how do perform below requirement in unix. Step1:we will receive multiple files weekly with same name(as below) in a folder(In folder we will have other files also def.dat,ghf.dat) Filenames: 1) abc_20171204_052389.dat 2)abc_20171204_052428.dat DON'T modify... (23 Replies)
Discussion started by: sunnykamal59
23 Replies

2. Shell Programming and Scripting

Using cat and pipeline to execute script

hi this is a homework assignment i need some help with it mostly works. script file #!/usr/bin/env bash #create dictionary file grep -E '.{3}' /usr/share/dict/british-english > db.txt #create remove_word to test file touch removeW.txt #palindrome function palin() { ... (1 Reply)
Discussion started by: crepe6
1 Replies

3. Shell Programming and Scripting

Run rest of script after parallel steps have completed

Hello gurus, I produce a number of .loc files in parallel depending on number of .csv in the folder for file in *csv do ./process.sh $file > $file.loc & done then I want to compile all the output from the previous step into a single masterlocfile and then perform the rest of the steps... (2 Replies)
Discussion started by: senhia83
2 Replies

4. Shell Programming and Scripting

Script for moving series of sub folders

Hello, I'm new to this forum. Did a search but I didn't quite find what I was looking for. This is probably a fairly easy request but I'm just not sure how to accomplish this. I have a folder structure that looks something like this:/names/company1/archive /names/company1/newarchive ... (4 Replies)
Discussion started by: vipertech
4 Replies

5. Shell Programming and Scripting

Execute script in series of folders

I'm trying to get a script to iterate of an array in bash run a series of commands in those folders. #Folder names folders=(folder1 folder2 folder3) #Common path for folders fold_path="/Users/Rich/Projects/" # For each element array copy script to folder and execute for f in... (2 Replies)
Discussion started by: 3therk1ll
2 Replies

6. Shell Programming and Scripting

Shell script with mutiple steps/commands, on UNIX servers

Hi, I wrote a simple script, which will call other scripts or run commands on a UNIX server. my script has multiple steps/commands with some delay in between. I usually get some email notifications after the successful execution of each step. **My intention is to get email alerts when it is... (5 Replies)
Discussion started by: System Admin 77
5 Replies

7. Shell Programming and Scripting

Running a script over a series of files

Hi, I want to run a script over a series of files with the names : Sample_1.sorted.bam Sample_2.sorted.bam Sample_3.sorted.bam How can I specify it in my script. Thanks a lot in advance. (3 Replies)
Discussion started by: Homa
3 Replies

8. Shell Programming and Scripting

Can we execute series of commands from a single script?

Hi, I am trying to call a certain command from within a shell script, but everytime it executes the script, only the first command runs and it comes out of the control, how do i do it? code : ```````` #!/bin/sh # # #i=1 #while #do # i=`expr $i + 1` #done StoreXML -project xnat -l... (2 Replies)
Discussion started by: virendra maloo
2 Replies

9. UNIX for Advanced & Expert Users

Changing Unix form to Microsoft Word form to be able to email it to someone.

Please someone I need information on how to change a Unix form/document into a microsoft word document in order to be emailed to another company. Please help ASAP. Thankyou :confused: (8 Replies)
Discussion started by: Cheraunm
8 Replies
Login or Register to Ask a Question