How to use unix commands in awk


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to use unix commands in awk
# 1  
Old 12-26-2006
How to use unix commands in awk

Hi All,
I try to use the unix commands inside awk and couldnt succeed .
Please help me how to achieve it.







Regards,
Sukumar.
# 2  
Old 12-26-2006
where exactly are you stuck?
# 3  
Old 12-26-2006
Inside the awk.

echo $h|awk '{
"if [ "'$h'" -eq "hi" ]
then
echo "Success"
else
echo "Failure"
fi"
}'

I dont know where iam right or not.please help me
# 4  
Old 12-26-2006
don't understand what you're trying to achieve, but.....
look into 'system' call on awk's man page.

or
Code:
cmd="date"
cmd | getline myDate
close(cmd)
printf("NOW -> [%s]\n", myDate)

# 5  
Old 12-26-2006
judging from what you want to do in your awk portion, you could have just
done simple comparison in shell, no need for awk.
# 6  
Old 12-26-2006
This is not just a comparison

Hi ghostdog,

This is not just a comparison,I am trying to achieve deletion and moving of files after text processing.

The below example is a simple try for unix commands inside awk.






Regards,
Sukumar.
# 7  
Old 12-26-2006
Can you post here your exact requirement in detail i.e. post here what you want to achieve not how you want to achieve. Thanks. Regards, Tayyab
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

AWK commands, in different OS

I have developed a bash shell script which works perfectly fine when any bash shell is in use except SunOS. There are two commands that is not compatible. #!/usr/bin/env bash Problem 1. The awk command below does not work for SunOS Requirement We extract Oracle EBS tables into text... (9 Replies)
Discussion started by: uuuunnnn
9 Replies

2. Shell Programming and Scripting

Help me in awk commands

can you please let me know what does the below awk command does. awk 'NR>2{printf "%-30s %-15s\n", $1, !($4)?$2:$4;}' result.txt (1 Reply)
Discussion started by: ramkumar15
1 Replies

3. UNIX for Dummies Questions & Answers

UNIX commands in AWK

Hi, I have 2 lists of words and I need to take every line in first_list.txt and use agrep command to find similar words in whole second_list.txt. I tried to use AWK, but I dont know how to take current line ($0) and use in inside of agrep cat first_list.txt | awk '' Thanks for help (10 Replies)
Discussion started by: m4rty
10 Replies

4. Fedora

Help with Unix commands

Hi, I have the following file called addresses, (it is a large file i have only copy and pasted few of the data below) and I am wanting to write a command so it will Find the ratio of mobile (07....) to land line (01....) telephone numbers? then find the most popular first name and list the... (2 Replies)
Discussion started by: tina_2010
2 Replies

5. UNIX for Dummies Questions & Answers

Help with Unix Commands

Hello everybody, I am a newbie in Unix/Linux so please excuse me!:o Could somebody please explain to me what the following Unix commands do or mean: ls -al | grep "*.c" | wc -l >> log.txt and ps -el | grep "*tty*" | uniq | sort > log.txt I know 'grep' means to find a text... (4 Replies)
Discussion started by: kev_1234
4 Replies

6. UNIX for Dummies Questions & Answers

Running UNIX commands remotely in Windows box from Unix box – avoid entering password

I am able to run the UNIX commands in a Windows box from a UNIX box through "SSH" functionality. But whenever the SSH connection is established between UNIX and Windows, password for windows box is being asked. Is there a way to avoid asking password whenever the SSH connection is made? Can I... (1 Reply)
Discussion started by: D.kalpana
1 Replies

7. UNIX for Dummies Questions & Answers

Help with these unix commands!

Hi to all, I have just started to learn Unix, and am having problems trying to understand the following two unix commands. if any1 could help i would greatly appreciate it. 1) ls -s | sort -nr | head -3 2) man -k c | grep -i ' c* ' | grep 1 i understand that for 1) the command will... (7 Replies)
Discussion started by: Vn3050
7 Replies

8. Shell Programming and Scripting

combining unix commands and awk program

Dear Experts I am trying to find if it is possible to combine unix commands in awk program. For example if it is possible embed rm or ls or any unix command inside the awk program and while it is reading the file besides printing be able to do some unix commands. I am thinking may be just print... (2 Replies)
Discussion started by: Reza Nazarian
2 Replies

9. Windows & DOS: Issues & Discussions

Unix commands

I am trying to find the difference between the sum and join commands in Unix. If there is one, what is it? and what they do :cool: (1 Reply)
Discussion started by: Darwin Rodrigue
1 Replies

10. UNIX for Dummies Questions & Answers

Maingrame to UNIX sending UNIX commands

I want to know if there is a way to send unix commands thru FTP from a mainframe to kick off Autosys Jobs. I just need to send a command from the mainframe to UNIX and have UNIX execute that command. (2 Replies)
Discussion started by: skammer
2 Replies
Login or Register to Ask a Question