1.) instead of reading the content of your search keys into an array in advance you should read this file line by line in a pipeline. Arrays are limited in size and you may run into a situation where the number of search keys exhaust the maximum number of available array elements. You will have to decide for yourself how big the chance of this happening is in your case.
2.) Don't use the old-style subshell mechanism any more. Instead of "x=`command`" use "x=$(command)"
3.) The reason why a search key consisting of several words is not being searched in its entirety but only one word after the other is because you haven't protected your variables enough. The shell tends to interpret values and especially splits words at word boundaries (read: whitespace). To prevent the shell from doing so is the whole point of quoting. This makes the difference between 'x=$y' and 'x="$y"'. You can easily test this by issuing the following series of statements at the commandline:
# touch "foo bar"
# ls -1
# foo bar
# touch foo bar
# ls -1
foo bar
foo
bar
# ls -1 foo bar
foo
bar
# ls -1 "foo bar"
foo bar
Having said that, the script would look like the following sketch (note the quotes in the line starting with grep):
Hello,
I have a file called Delete and within the delete file I have the following statement:
delete from employee where employee_id = " "
how do I write a script that read from this file and replace:
employee_id = " " with employee_id is null
Please assist...greatly... (3 Replies)
Hello!!
I'm want to read each line of a file.
I'm doing a cut command, using \n - linefeed as delimeter and "list" as my file.
cut -f1 -d"\n" -s < list
Changing the file, putting spaces and doing cut -f1 -d" " -s < list it works, but with linefeed nothing is returned.
Thanks... (5 Replies)
I have read another post about this issue and am wondering how to adapt it
to my own, much simpler, issue.
I have a file of user IDs like so:
333333
321321
546465
...etc
I need to take each number and use it to print records wherein the 5th
field matches the user ID pulled from the... (2 Replies)
I need to read data from a file called "test.csv" through shell script where the file contains values like name,price,descriptor etc. There are rows where descriptor (& in some rows name) are written as string & other characters like "car_+" OR "bike*" etc where it should contains strings like... (3 Replies)
Enclosed is comma separated text file. I need to write a korn shell program that will parse the text file and insert the values into Oracle database.
I need to write the korn shell program on Red Hat Enterprise Linux server.
Oracle database is 10g. (15 Replies)
Hi ,
I am trying to write an shell, which reads a text file (from a location) having a list of numbers of strictly 5 digits only ex: 33144
Now my script will check :
1) that each entry is only 5 digits & numeric only, no alphabets, & its not empty.
2)then it executes a shell script called... (8 Replies)
this is my issue.
4 parameters are passed from korn shell to sql script.
parameter_1= varchar2 datatype or no value entered my user.
parameter_2= number datatype or no value entered my user.
parameter_3= number datatype or no value entered my user.
parameter_4= number datatype or no... (5 Replies)
For eg: I have sample.txt file with 4 rows of record like:
user1|password1
user2|password2
user3|password3
user4|password4
The username and password is sepsrated by '|'
I want to get the 1st row value from the file and assign it to two different variables(username and password)
in my... (1 Reply)
Hi,
I need a shell script, which would search the result values from another files.
1)execute " select column1 from table_name" query on the table.
2)Based on the result, need to be grep from .wft files.
could please explain about this.Below is the way i am using.
#!/bin/sh... (4 Replies)
I have a file containing multiple values, some of them are pipe separated which are to be read as separate values and some of them are single value all are these need to store in variables.
I need to read this file which is an input to my script
Config.txt
file name, first path, second... (7 Replies)