dynamic string searching for grep


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting dynamic string searching for grep
# 1  
Old 10-04-2012
dynamic string searching for grep

hi my code is something like





Code:
   count=0
     echo "oracle TABLESPACE NAME  nd TARGET"

      while [ loop condition ]
      do
               count=`expr $count + 1`

             (1)     tts_space_name$count=`echo $tts | cut -d "," -f$count`

       (2) target$count=grep $(tts_space_name$count) cfg.txt | cut -d'=' -f2
      done

in line (1) value is getting assigned to tts_space_name$count , but den it is displaying error as no data found as shown
'
Code:
tts_space_name1=TBS_ADOX_EXTR3:  not found.

'

then in line (2) i want to give dynamic string to grep command , getting error as no error found ...




help in either case will be appreciated .... Smilie
plz help.

Last edited by Scrutinizer; 10-04-2012 at 04:48 AM.. Reason: code tags
# 2  
Old 10-04-2012
try something like this..

Code:
for i in {1..5}; do
eval var$i='$i'
done

for i in {1..5}; do
eval echo "$`echo "var$i"`"
done

1
2
3
4
5

# 3  
Old 10-04-2012
1) pls use code tags for your code & data
2) post the result of echo $tts and echo $tts | cut -d "," -f$count
3) grep will use variables, but you did not define/assign one due to an error.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

dynamic thread in grep

hi name$count = some dynamic value now i want to use dat dynamic value in grep so how m i supposed to do dat i tried `grep $(name$count) source` , it is not working ...... what will be after grep so dat i will be... (4 Replies)
Discussion started by: Gl@)!aTor
4 Replies

2. Shell Programming and Scripting

Help with dynamic value string

Hi all, Need help to seek string with dynamic value that always change? Example string JOB_WORK_STAFF_MARY_JANE_20111013_000000001.DAT "JOB_WORK_STAFF_" and "_20111013_000000001.DAT" is static length. How do I select the "MARY_JANE" in the middle of the string. Please advice. ... (5 Replies)
Discussion started by: shadow_max85
5 Replies

3. Shell Programming and Scripting

Dynamic Grep

Experts, Hi there. Feel like kicking myself today as I wish I could have paid more attention to learning while I was in college. If only wishes were horses .... Anyway, Im parsing the contents of a log file. Now what I need to do here is search for a pattern and then Pick the top 3... (6 Replies)
Discussion started by: OMLEELA
6 Replies

4. Shell Programming and Scripting

grep searching interval

Hi all, I just want to find all values that are in a specified interval. I tryed it with grep e- file , it does not work. Is it possible to get values wich are lower a special number, like grep >e-18 file? Thanks a lot (4 Replies)
Discussion started by: newcommer
4 Replies

5. Shell Programming and Scripting

searching the required string and appending string to it.

Hi all, I have some data in the form of adc|nvhs|nahssn|njadnk|nkfds in the above data i need to write a script so thet it will append "|||" to the third occurnace in the string ..... the outout should look like adc|nvhs|nahssn||||njadnk|nkfds Thanks, Firestar. (6 Replies)
Discussion started by: firestar
6 Replies

6. Shell Programming and Scripting

grep searching

I am making a script but having little problem. at one part I need to find one number format or other format from a file.. those formats are xxx-xx-xxxx or xxxxxxxxx i tried grep '( \{3\}-\{2\}-\{3\} |\{9\})' if i do them sepratly it work but like this it is not working Please check... (7 Replies)
Discussion started by: Learnerabc
7 Replies

7. Shell Programming and Scripting

searching using grep command

Hi, i have a file called alert_pindb.log i need to grep and count for all the lines starting with "ORA-" but i need to exclude the line which is having "ORA-00600 " i am using following syntax to count the ORA- nos "grep \"ORA-\" alert_pindb.log | wc -l"; since ORA- may be anything... (9 Replies)
Discussion started by: prakash.gr
9 Replies

8. Shell Programming and Scripting

Extracting a string from one file and searching the same string in other files

Hi, Need to extract a string from one file and search the same in other files. Ex: I have file1 of hundred lines with no delimiters not even space. I have 3 more files. I should get 1 to 10 characters say substring from each line of file1 and search that string in rest of the files and get... (1 Reply)
Discussion started by: mohancrr
1 Replies

9. Shell Programming and Scripting

GREP Searching for a newbie...

Hi, I really need some help with GREP searching... I need to find all occurances of a file reference and remove two characters from the end of the reference. For example, here are a few lines showing the text: <image file="STRAIGHT_004CR.jpg" ALT="STRAIGHT_004CR.jpg" /> <image... (8 Replies)
Discussion started by: steveglevin
8 Replies

10. Shell Programming and Scripting

grep - searching for a specific string

ppl, this is my "file" with fields orderno orderdate orderdesc telno street city 1 01/04/2006 abc 123 100 tampa 2 01/04/2006 abc 123 100 tampa 3 01/04/2006 abc 123 100 tampa 4 01/04/2006 abc ... (2 Replies)
Discussion started by: manthasirisha
2 Replies
Login or Register to Ask a Question