In my first attempted script I have run a=`cat file_source`, then in a do loop, tried to grep "$a" file_another.
This is not advisable for several reasons: first - as you noticed - field splitting will occur and may bite you in the behind. Second, there is a much easier way to do this, see below.
Quote:
Originally Posted by Brusimm
I've tried multiple ideas, from cat, to read, to while to screaming. (OK, screaming is not a function, just a reaction.)
I can get a while read routine to read the whole line of file_source, but then trying to use the line to grep for in file_target fails wonderfully, saying something to the effect of source not found or what not.
Not seeing your script i can only speculate but probably the problem was quoting (or, rather, the lack thereof). You probably did:
Notice that you always ALWAYS have to protect your variables - you don't go outside naked, they shouldn't be made to go outside unquoted. Do it like:
But there is a much better way and it doesn't even involve a script - TADAAAAHHHH:
Quote:
Originally Posted by Brusimm
If anyone has quick suggestions, outlines, ideas, or examples, WITHOUT burning up too much of your time, I'd appreciate it.
Well, sometimes, when the time is right, i can make a little room in my busy schedule which is filled with coming up with witty formulations for heightening the suspense and avoiding to lead to a premature climax of this most interesting topic ......*)
...to come up with a single command that does it all: grep!
Do it like this:
and grep will read the file_with_phrases, line by line, then do a search in the other file for that line. Sounds like this is what you wanted, no? To find out more about how to use grep i suggest to peruse the man page. If you still have questions, you'll be welcome.
I hope this helps.
bakunin
__________
*) You might not believe it but i can prolong that for a nearly indefinite time.
Hi,
I need to write a shell script (ksh) to read contents starting at a specific location from one file and append the contents at specific location in another file. Please find below the contents of the source file that I need to read the contents from,
File 1
-----# more... (5 Replies)
Hi
How can i dynamically read files names from a list file and execute them from a single shell script.
Please help its urgent
Thanks in Advance (4 Replies)
I have a file which has following contents:
localhost_IP_SIP_1233026552455.xml
localhost_IP_SIP_1233026552460.xml
localhost_IP_SIP_1233026552467.xml
localhost_IP_SIP_1233026552759.xml
localhost_IP_SIP_1233026552969.xml
localhost_IP_SIP_1233026552975.xml ... (2 Replies)
I have a file named as ucid.txt
It has multiple rows of "id". I need to search and grep each line of it from a file named as pw_logs.txt and put the results into another file.
Please help ! Thanks. (8 Replies)
Hi All,
Need help on this
I have 2 files
one file file1 which has several entries as :
define service{
hostgroup_name !host1,!host5,!host6,.*
service_description check_nrpe
}
define service{
hostgroup_name !host2,!host4,!host6,.*
service_description check_opt
}
another... (2 Replies)
Hi Guys,
I need to read a file until I find a blank line. and in the next iteration I want to continue reading from the line I find a keyword.
For ex: my file looks like
PDS_JOB_ALIAS
CRITERIA_ITEM_TYPE
PDS_JOB_CRITERIA_ITEM
CRITERIA_ITEM_TYPE
First I want to read the file... (2 Replies)
Hi,
I am doing something basic, but I am missing something. Im trying to read the contents of a file and taking those values and connecting to a database. However, it only connect to one (or reads in) value and then exists.
Here is what it looks like:
listname.txt
db1
db2
db3
Script:... (15 Replies)
We're using a ksh script for installing one product.
I've another config file, I'd need to read this configuration file from my main script
Content of the Configuration file:... (2 Replies)
Shell script logic
Hi
I have 2 input files like with file 1 content as (file1)
"BRGTEST-242" a.txt "BRGTEST-240" a.txt "BRGTEST-219" e.txt
File 2 contents as fle(2)
"BRGTEST-244" a.txt "BRGTEST-244" b.txt "BRGTEST-231" c.txt "BRGTEST-231" d.txt "BRGTEST-221" e.txt
I want to get... (22 Replies)