awk and execute


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting awk and execute
# 1  
Old 10-15-2008
awk and execute

Hi All,


I need this to execute and not just print on Red Hat ent 4 bash shell.

cat /etc/passwd|grep db2 | awk -F":" '{print "cat /etc/group | grep ",$4}'

Output:

cat /etc/group | grep 1000 (I don't want this to print but execute)




Thanks for any comment you may add.
# 2  
Old 10-15-2008
Use system() function
Code:
awk -F":" '/db2/{system("grep "$4" /etc/group")}' /etc/passwd

# 3  
Old 10-15-2008
Thanks but how come it's multiplying by 2 (or more, depending on how many members).

But this will fix it: awk -F":" '/db2:/{system("grep "$4" /etc/group")}' /etc/passwd

Last edited by itik; 10-15-2008 at 04:25 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Execute awk output with continuous streaming input

I need to parse some continuous output from a program (i.e. aScript.py) into a portal that uses curl. I've written a simple awk one-liner to parse the information that is output from aScript.py, but I'm not able to execute it. I can succeed with just one line of the output from aScript.py: echo... (2 Replies)
Discussion started by: jm4smtddd
2 Replies

2. Shell Programming and Scripting

Execute command from awk

This seemed straight forward until I tried to code it. I'm running ioscan -fuNC disk to get list of disk including hardware path. What I'm trying to do is use awk to take this output, extract hardware path, and pass that as a variable to ioscan -P wwid -N -H 64000/0xfa00/0x1a | grep ^disk and... (11 Replies)
Discussion started by: steve72
11 Replies

3. Shell Programming and Scripting

remote execute awk script

Hi gurus I need to execute awk command on remote machine and write output to stdout. So far Ive tried: ssh server "ifconfig | grep -A 1 "^eth" | awk '{if ($1~/^eth/) {temp=$1} else {print temp $0}}'" ssh server "exec " < file_containing_above_command But neither works Without awk... (9 Replies)
Discussion started by: wakatana
9 Replies

4. Shell Programming and Scripting

execute c

i wish to have a shell script which receives the file name and path (from the user) to a text file that contains a c program and compiles the program code using gcc and displays the execution of the compiled file (which is saved as filename.c) in the terminal / konsole Can any one help me by... (1 Reply)
Discussion started by: anurag.mishra1
1 Replies

5. Shell Programming and Scripting

How to execute local function in awk

Hi All, Can you please tell me how to execute local function written in a shell script with awk. i tried with system command but its giving an error. (1 Reply)
Discussion started by: krishna_gnv
1 Replies

6. Shell Programming and Scripting

awk and execute app

Ahoy, New to Ksh and Perl. Spent days googling and trying things before finding this site. Search this site for solution. What I want is to automate the typing of a command on a HPUX 11 server. The command is particular to Perforce and their excellent tech support suggested I do this in Perl. ... (0 Replies)
Discussion started by: tyger52
0 Replies

7. Shell Programming and Scripting

script execute or no execute

o hola.. Tengo un script que se ejecuta bajo una tarea del CronJOb del unix, tengo la version 11 de unix, mi script tiene un ciclo que lee unos archivos .txt luego cada uno de esos archivos debe pasar por un procedimiento almacenado el cual lo tengo almacenado en mi base de datos oracle 10g,... (4 Replies)
Discussion started by: Kespinoza97
4 Replies

8. Shell Programming and Scripting

Need to execute 2 scripts, wait, execute 2 more wait, till end of file

:cool: I need to execute a shell script to do the following: cat a file run two back ground processes using the first two values from the file wait till those background processes finish run two more background processes using the next two values from the file wait till those background... (1 Reply)
Discussion started by: halo98
1 Replies

9. Shell Programming and Scripting

awk and execute command ???

If I have a flat file date.txt separate by a tab date1 date2 count 20060226 20060225 2 20060227 20060226 2 20060228 20060227 5 20060314 20060228 2 20060315 20060314 1 If $3 (count) is 5 then execute the script testit.ksh with... (13 Replies)
Discussion started by: sabercats
13 Replies

10. Shell Programming and Scripting

how to execute shell commands in awk script?

Greetings Friends, Suppose I wish to invoke some shell level commands inside an awk script how to do that? say I wish to use : "wc" on a record to count number of characters in a record Any clues? Thanks, Rishi (1 Reply)
Discussion started by: RishiPahuja
1 Replies
Login or Register to Ask a Question