Display match or no match and write a text file to a directory
The below bash connects to a site, downloads a file, searches that file based of user input - could be multiple (all that seems to work). What I am not able to figure out is how to display on the screen match found or no match found" and write a file to a directory (C:\Users\cmccabe\Desktop\wget) with the match in it. If there is no match then no file needs to be created just displayed. Thank you .
Last edited by cmccabe; 01-08-2016 at 04:17 PM..
Reason: added details
What exactly do you expect
- grep -n "${id}" getCSV.txt (note: id is an array)
- printf ${id[$i] & ${result[$i]}} (note: result is not an array)
to do?
Looks like I have a bit of work to do, what would you do? I am making progress learning programming, but am still a scientist who wants to learn. Thank you .
What you don't seem to recognize is that you have a mixture of processing an array of id values along with getting a single scalar result value. And, after getting an array of id values and getting a single result value you are then using a for loop to process the values in the id array without getting result values associated with each element of the id array. That just can't work.
I don't follow the logic of what your script is trying to do, and the inconsistent indentation in your script doesn't help. This is totally untested, but might provide an idea for a way to move forward on your project. Note that (unlike Aia's suggestion and your code), this gathers one ID at a time rather than an array of IDs. Otherwise, I think this code follows the intended flow of your code more closely than Aia's suggestion. But, I may have misread the intent of your code:
This User Gave Thanks to Don Cragun For This Post:
hi all,
trying this using shell/bash with sed/awk/grep
I have two files, one containing one column, the other containing multiple columns (comma delimited).
file1.txt
abc12345
def12345
ghi54321
...
file2.txt
abc1,text1,texta
abc,text2,textb
def123,text3,textc
gh,text4,textd... (6 Replies)
Having a little trouble getting this to work just right.
I have xml files that i want to split some data.
I have 2 <name> tags within the file
I would like to take only the first tag and split the data.
tag example.
From this.
TAB<Name>smith, john</Name>
to
TAB<Name>smith,... (8 Replies)
In the below bash I am trying to rename eachof the 3 text files in /home/cmccabe/Desktop/percent by matching the numerical portion of each file to lines 3,4, or 5 in /home/cmccabe/Desktop/analysis.txt. There will always be a match between the files. When a match is found each text file in... (2 Replies)
I am trying to create a cronjob that will run on startup that will look at a list.txt file to see if there is a later version of a database using database.txt as the source. The matching lines are written to output.
$1 in database.txt will be in list.txt as a partial match. $2 of database.txt... (2 Replies)
not getting anywhere with this
an xml file contains multiple clients set up with same tags, different values.
I need to parse the file for client foo, and change the value of tag "64bit" from false to true.
cat clients.xml
<Client type"FIX">
<ClientName>foo</ClientName>... (3 Replies)
Hi Friends,
I'm a great fan of this forum... it has helped me tone my skills in shell scripting. I have a challenge here, which I'm sure you guys would help me in achieving...
File A has a list of job ids and I need to compare this with the File B (*.log) and File C (extend *.log) and copy... (6 Replies)
Hi Forum:
I have struggle with it and decide to use my eye ball to accomplish this.
Basically I am looking for sequence of date inside a file.
If one of the sequence repeat 2-3 time or skip once; it's still consider a match.
input text file:
Sep 6 A
Sep 6 A
Sep 10 A
Sep 7 B
Sep 8... (7 Replies)
Hello, can someone help me how to find a word and 2 lines after it and then send the output to another file.
For example, here is myfile1.txt. I want to search for "Error" and 2 lines below it and send it to myfile2.txt
I tried with grep -A but it's not supported on my system.
I tried with awk,... (4 Replies)
I am trying to sort the following files from folder Bag to Apple, Cat Food, Dog Food. I can get all of the files I want into a new folder, but not sure of the best approch to get them to their final directory
My Files
==========
apple.1234.ext
apple.1235.ext
cat food 101.ext
Cat Food... (2 Replies)
Hi all
I have two files X.txt and Y.txt. Both file contains same number of sentences. The content of X.txt is
The filter described above may be combined.
and the content of Y.txt is
The filter describ+ed above may be combin+ed.
Some of the words are separated with "+"... (2 Replies)