Creating executable script--please help

Hi group,
I am very beginner in shell scripting and self learning.
I am trying to create and executable script to run awk from user defined variables.

e.g. suppose from a given file I want to delete some rows or some columns
We need to repeat this process for many files. Thus I was trying to write a script. Any help will be really great.
This is my progress so far:

# A script to modify delete particular row and column from tab delim files
osch=0
echo "1. Delete row from file"
echo "2. Delete columns from file"
echo "Select your choice [1 or 2]?"
read osch
if [$osch -eq 1]; 
then
        echo "Enter row numbers with space"
        read x
        echo 'You entered this line: ' $x
        set -A rarray $x
        do 
                awk 'NR!={rarray[@]}' INPUT > INPUT_modified
        done
        echo "Modified file is created"
fi

if [$osch -eq 2]; 
then
        echo "Enter column numbers with space"
	read y
        echo 'You entered this line: ' $y
	set -A rarray $y
        for i in
        do 
	     awk '{for(i=1;i<=NF;i++)if(i!={rarray[@]})printf '%s', $i OFS;print""}' INPUT > INPUT_modified
        done
        echo "Modified file is created"
fi

As a beginner this is just a try. PLEASE HELP
Thanks a lot in advance :slight_smile:

---------- Post updated at 12:58 PM ---------- Previous update was at 10:09 AM ----------

Any body in the group...please help. I am really stuck in here :confused:.

What is not working or what is missing? (give the output if you have errors...)

this is the output so far...

1. Delete row from file
2. Delete columns from file
Select your choice [1 or 2]?
1
./test-array: line 14: syntax error near unexpected token `do'
./test-array: line 14: `        do '
smitra:Desktop smitra$ 

And further I am having a problem to name the modified file as (Input)_modified.
Any help will be really great.
Thanks

as of now i found below issues, please check..

if [ $osch -eq 1 ]; #Space is needed in square brackets for first and second if.

#in first if there is no for loop ahead of do

for i in # i think you are checking for the areray elements .. add to the in..

Hi Pamu,
Thank for the reply. I tried to put space in the square bracket. But still the same problem And I am not sure how to fix the loop. :confused:

osch=0
echo "1. Delete row from file"
echo "2. Delete columns from file"
echo "Select your choice [1 or 2]?"
read osch
if [ $osch -eq 1 ]; 
then
        echo "Enter row numbers with space"
        read x
        echo 'You entered this line: ' $x
        set -A rarray $x
        do 
                awk 'NR!={rarray[@]}' INPUT > INPUT_modified
        done
        echo "Modified file is created"
fi

if [ $osch -eq 2 ]; 
then
        echo "Enter column numbers with space"
	read y
        echo 'You entered this line: ' $y
	set -A rarray $y
        do 
	     awk '{for(i=1;i<=NF;i++)if(i!={rarray[@]})printf '%s', $i OFS;print""}' INPUT > INPUT_modified
        done
        echo "Modified file is created"
fi

Here are the same error again:

1. Delete row from file
2. Delete columns from file
Select your choice [1 or 2]?
1
./test-array: line 14: syntax error near unexpected token `do'
./test-array: line 14: `        do '