UNIX commands in AWK


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers UNIX commands in AWK
# 8  
Old 01-19-2011
Quote:
Originally Posted by m4rty
I would like to use more than one command, or something else (like grep). So I would use first one, the loop.But Idk why it doesnt work.
Why doesn't the loop work? What output do you get and what are your inputs?
# 9  
Old 01-19-2011
Quote:
Originally Posted by sharfah
Why doesn't the loop work? What output do you get and what are your inputs?
I used
Code:
input
first.txt
car
mama
flash
monitor

second.txt
cocacola
car
busstop

while read pattern; do grep '$pattern' first.txt; done < second.txt

I dont get any output :-(
# 10  
Old 01-19-2011
Use double quotes instead of single quotes:

Code:
while read pattern; do grep "$pattern" first; done < second

# 11  
Old 01-19-2011
ohhh man, IT WORKS :-). THANKS MAN
 
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. 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

4. 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

5. 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

6. 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

7. Shell Programming and Scripting

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. (7 Replies)
Discussion started by: jerome Sukumar
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