Question about partial searching


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Question about partial searching
# 15  
Old 10-15-2010
sorry, I should've clarified with an example

so lets say theres a few names in a list

whether the user enters it eter, Pete, ter

it should output Peter as a match. A partial or full match basically
# 16  
Old 10-15-2010
Ah, you mean substring.

In BASH and KSH you can do matching like

Code:
if [[ "$HAYSTACK" == *"${NEEDLE}"* ]]

# 17  
Old 10-16-2010
Quote:
Originally Posted by Sagramor
./test: line 5: conditional binary operator expected
./test: line 5: syntax error near `=~"Name1"'
./test: line 5: ` [[ "$S" =~"Name1" ]] && echo "Name: $Name1 ${L:43:15}"'
Then use the following syntax (alternative proposed in my first post):
bash code:
  1. read -p "Enter search string : " S
  2. while read L
  3.    Name1=${L:11:14}
  4.    grep "$S" <<< "Name1" && echo "Name: $Name1 ${L:43:15}"
  5. done <playerlist
# 18  
Old 10-17-2010
that code seems to terminate after I enter in the string that I want to search
# 19  
Old 10-18-2010
Which?
# 20  
Old 10-18-2010
the one Frans was referring to Smilie
# 21  
Old 10-19-2010
Try putting an 'echo something' in the loop to see if the loop's running at all.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Partial Match and Replace

Hi, I have a tab delimited text file like this one. I need to do a partial match of a particular cell and then replace matches with an empty cell. So here is a sample: Smith FordMustang ChevroletCamaro Miller FordFiesta Jones KiaSorrento Davis ChevroletCamaro Johnson ToyotaHighlander I... (4 Replies)
Discussion started by: mikey11415
4 Replies

2. UNIX for Dummies Questions & Answers

How to substitute for the partial match?

Hi I have a question and hope I can get answer here. Thank you in advance. I have two files: file1: aa X bb Y cc Z file2: cc A bb B dd C aa D bb E If the 1st column match in both file1 and file2, the 2nd column in file2 will be replaced by the 2nd column in file1. If there is no... (2 Replies)
Discussion started by: yuejian
2 Replies

3. Shell Programming and Scripting

URL partial matching

I have two files: file 1 http://www.hello.com http://neo.com/peace/development.html, www.japan.com, http://example.com/abc/abc.html http://news.net http://lolz.com/country/list.html,www.telecom.net, www.highlands.net, www.software.com http://example2.com ... (1 Reply)
Discussion started by: csim_mohan
1 Replies

4. Shell Programming and Scripting

Partial retrieve

I have this in log file /var/log/maillog XXX YYY ZZZ :15214 I=:25 AAA BBB CCC I need awk/sed operation on this, so that it retrieves only the first IP. cat /var/log/maillog | sed_operation 55.66.77.88 (2 Replies)
Discussion started by: anil510
2 Replies

5. Shell Programming and Scripting

How to replace partial string

I have a list of strings in file: 10 10 AAA 120 13 BBBBB 23 11 CCCCC 11 32 DDDDDD I want to replace first column of the text such as: 10, 129, 23, 11 with 11, 22, 33, 44. I can do line by line, but just not sure how to replace partial string without... (1 Reply)
Discussion started by: ford99
1 Replies

6. Shell Programming and Scripting

AWK - Print partial line/partial field

Hello, this is probably a simple request but I've been toying with it for a while. I have a large list of devices and commands that were run with a script, now I have lines such as: a-router-hostname-C#show ver I want to print everything up to (and excluding) the # and everything after it... (3 Replies)
Discussion started by: ippy98
3 Replies

7. Shell Programming and Scripting

Partial Delete Lines

Hi, Need to delete line prior to (INSERT/UPDATE/DELETE). In case ' available, then keep that. Pls refet below details. Input ====================== l_s := ' INSERT INTO TEST' l_P PD := ' UPDATE INTO TEST' l_D := ' DELETE INTO TEST' This is test Output... (4 Replies)
Discussion started by: saurabhbaisakhi
4 Replies

8. Shell Programming and Scripting

get partial numbers from a string

Hi Everyone, I have: $val="QQ3_1899_CD4". The output will be: 1899. I did $val =~ /(\d+)/g; the output is 318994, then i use substr to get those 1899. This is not efficient. Is any simple way, like just one line can do? Thanks (1 Reply)
Discussion started by: jimmy_y
1 Replies

9. UNIX for Dummies Questions & Answers

Searching partial columns and returning maximum as output

Hello, I am just getting starting with awk and wondering if anyone could help with the following problem. I have a large file of data, 50,000 rows x 6 columns. I would like to search in blocks of 500 rows for a maximum value in a specific column and compile an output file that prints the... (0 Replies)
Discussion started by: xb_analysis
0 Replies

10. UNIX for Dummies Questions & Answers

searching text question

If I am searching through a text file, and it is setup in hierarchical fashion. ie: Memory: 256 MB DDR Kingston CPU: UltraSparc 800 Mhz can i somehow search for CPU and pull out lines below it as well? Like grep only pulls that one line, i want that line... (4 Replies)
Discussion started by: BG_JrAdmin
4 Replies
Login or Register to Ask a Question