dynamic thread in grep


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting dynamic thread in grep
# 1  
Old 10-04-2012
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 able to grep dat dynamic value ......
m stuck
# 2  
Old 10-04-2012
try this for a fixed text pattern
Code:
grep -F "name$count"  sourcefile

# 3  
Old 10-04-2012
can we minimize this... Smilie
i have tried lot but not find any solutions yet..Smilie

Code:
grep $(eval echo "$`echo "name$count"`") file

# 4  
Old 10-04-2012
Maybe: grep "$(eval echo '$name'$count)"

However, if the OP's shell has arrays...
--
Bye

Last edited by Lem; 10-04-2012 at 11:24 AM..
# 5  
Old 10-04-2012
I can't tell what you're even trying to do, but in bash or new enough ksh you can do

Code:
ASDF="1234"
VARNAME="asdf"
echo "${VARNAME}=${!VARNAME}"

Login or Register to Ask a Question

Previous Thread | Next Thread

5 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grep username and get all the lines with thread numbers

I need help to extract the file. If I am entering the user name like abcd@xyz.com, search the username and get the tread number. Once will get thread number all the line having same threadnumber wanted to keep in seperate file. It can be more than thread number for single username. For... (3 Replies)
Discussion started by: nes
3 Replies

2. Shell Programming and Scripting

dynamic string searching for grep

hi my code is something like count=0 echo "oracle TABLESPACE NAME nd TARGET" while do count=`expr $count + 1` (1) tts_space_name$count=`echo $tts | cut -d "," -f$count` (2) target$count=grep $(tts_space_name$count)... (2 Replies)
Discussion started by: Gl@)!aTor
2 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. UNIX for Advanced & Expert Users

Sql dynamic table / dynamic inserts

I have a file that reads File (X.txt) Contents of record 1: rdrDESTINATION_ADDRESS (String) "91 971502573813" rdrDESTINATION_IMSI (String) "000000000000000" rdrORIGINATING_ADDRESS (String) "d0 movies" rdrORIGINATING_IMSI (String) "000000000000000" rdrTRAFFIC_EVENT_TIME... (0 Replies)
Discussion started by: magedfawzy
0 Replies

5. Programming

Creating an array to hold posix thread ids: Only dynamic array works

I am facing a strange error while creating posix threads: Given below are two snippets of code, the first one works whereas the second one gives a garbage value in the output. Snippet 1 This works: -------------- int *threadids; threadids = (int *) malloc (num_threads * sizeof(int)); ... (4 Replies)
Discussion started by: kmehta
4 Replies
Login or Register to Ask a Question