Question about partial searching


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Question about partial searching
# 22  
Old 10-19-2010
Too many <<< after grep when one or none would do? Or is that a bash-ism?
# 23  
Old 10-19-2010
Quote:
Originally Posted by DGPickett
Too many <<< after grep when one or none would do? Or is that a bash-ism?
It's a "here string" (one-liner "here document"-style thing). A bash- / ksh93-ism
# 24  
Old 10-19-2010
Maybe there are funny lines in the playlist?

If you really want to know who is doing what, there is truss -fae ! Faster than debug statements, and educational.

---------- Post updated at 03:47 PM ---------- Previous update was at 03:09 PM ----------

Seems kinda wild for this simple sed/shell, but it was a bash challenge. I think someone was a byte short, or did the req creep? This has a stdout free of prompts and such, but is sed metachar sensitive. One might use sed/cut to trim the key field out, grep to find interesting line numbers, and then pull the lines from the original.

Code:
echo 'Enter name to search: \c' >/dev/tty
read n
sed '
  h
  s/^.\{11\}\(.\{15\}\).*/\1/
  /'"$n"'/{
    g
    p
   }
  d
 ' playerlist

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