Execution of awk command in a variable


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Execution of awk command in a variable
# 1  
Old 08-07-2008
Data Execution of awk command in a variable

Hi All,

I have a awk command that is stored in a variable.

the value of the variable cmd is:
(mean output of echo $cmd is: )

awk -F";" '{print $1}'

Now I want to execute this command.

How can I do that????

Quick Reply will be appreciated.

Regards,
Amit
# 2  
Old 08-07-2008
try
Code:
eval $variable

# 3  
Old 08-07-2008
You are Great!

Its Working!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Variable in awk command

Hello All, I am trying to run a script to extract data from the file. The format of the file is as below: filename: sample.log 12345| ABCD 23456| GKHY 33454| ABCD 98765| TTRRI want to run a command in AWK as show below extract.sh #!/bin/bash echo... (2 Replies)
Discussion started by: chetanojha
2 Replies

2. Shell Programming and Scripting

Execution Problem with awk command

Hi All, I am trying to find a word from a file in loop. while read i; do DB_Name=$i awk '{for(i=1;i<=NF;i++)if($i~/$DB_Name/)print $(i)}' $BTEQ_NAME > $DB_Name_TableList.txt done <Param.txt here Param.txt contents data as ODS_TARGT_RECV FIN_TARGT... (7 Replies)
Discussion started by: Shilpi Gupta
7 Replies

3. Shell Programming and Scripting

Storing awk command in a variable

I'm working on a script in which gives certain details in its output depending on user-specified options. So, what I'd like to do is something like: if then awkcmd='some_awk_command' else awkcmd='some_other_awk_command' fi Then, later in the script, we'd do something like: ... (5 Replies)
Discussion started by: treesloth
5 Replies

4. Shell Programming and Scripting

Using variable in awk command

Have a small doubt . While using an iterator , i need to take the fields as seen as below . But the Iterator is not been displayed . Can you please help with this . Code: ITERATOR=0COUNT=`cat test.txt`echo "$COUNT" while do echo $ITERATOR echo "$COUNT" awk... (3 Replies)
Discussion started by: Ravi_Teja
3 Replies

5. Shell Programming and Scripting

Multiple command execution inside awk command during xml parsing

below is the output xml string from some other command and i will be parsing it using awk cat /tmp/alerts.xml <Alert id="10102" name="APP-DS-ds_ha-140018-componentFailure-S" alertDefinitionId="13982" resourceId="11427" ctime="1359453507621" fixed="false" reason="If Event/Log Level(ANY) and... (2 Replies)
Discussion started by: vivek d r
2 Replies

6. UNIX for Dummies Questions & Answers

Using a variable in the awk command

Hi Guys, Can anyone of you please tell me how to use a variable inside a awk command. For ex - if am printing the third column with respect to a pattern with delimiter ~ awk -F~ '$3=="pattern"' <file name> - This works, Now here I have a set of patterns in a file and I want to put it in... (1 Reply)
Discussion started by: abhisheksunkari
1 Replies

7. Shell Programming and Scripting

Variable in AWK command help

here is what i have so far delim=`cat $HOME/tmp/interchange_hold | head -1 | cut -b4` cat $HOME/tmp/rawfile_hold | ( while read line se_check=`echo $line | awk -F: -v awkvar="$delim" '{ print $1}'` delim will hold the 4th char of a file. Lets say that char is a * the line im... (2 Replies)
Discussion started by: blesjt02
2 Replies

8. Shell Programming and Scripting

Variable as input to awk command

Hi Gurus, I need a suggestion, please help. I have a input file as below : abc.txt : * xxxx: 00000 xxxxx: 00000 xxxx: RANDOM xxx: RANDOM **************************xxxxxxx*** * abc ****************************** abc: abc: ... (3 Replies)
Discussion started by: arunshankar.c
3 Replies

9. Shell Programming and Scripting

How to use same variable value inside as well as outside of the awk command?

Hi Jim, The following script is in working state. But i m having one more problem with awk cmd. Could you tell me how to use any variable inside awk or how to take any variable value outside awk. My problem is i want to maintain one property file in which i am declaring variable value into that... (12 Replies)
Discussion started by: Ganesh Khandare
12 Replies

10. Shell Programming and Scripting

Execution problems using awk command.

Hi All, I have the following requirement. In a directory i get files from external source. I at regular intervals check that directory for any incoming files. The file name is underscore delimited. Such as: aaa_bbb_ccc_ddd_eee_fff.dat I am using awk and and splitting the file name. ... (4 Replies)
Discussion started by: satishpv_2002
4 Replies
Login or Register to Ask a Question