Awk Related Question
I'm trying to get the following script to work.
Quote:
Here are examples of changes.txt and username.txt Quote:
Quote:
For example usernam1 would get an email with the following in the body: Quote:
|
Code:
while read line; do Well, first of all there's your variable. A bash variable can't expand when enclosed inside single quotes. To use a bash variable in awk, you either have to quote it carefully, or import it into an awk variable, as explained here. http://www.grymoire.com/Unix/Awk.html#uh-4 In addition, you generally only use a single print command per line, and you can't just use a carriage return to get the next line. awk has a special "getline" function for that (not to mention that newlines are represented by "\n" anyway). So here's my solution. I couldn't make it import and use an awk variable correctly :), but I did manage to get it to work by simply "unquoting" the variable. That is, the awk parts of the expression are in single quotes, and the bash variable is in double quotes. Code:
while read line; do |
Stupid me. I was making things too complicated. Here's a way to do it through importing the bash variable into an awk variable (the -v option).
Code:
while read line; do |
Is not enough using grep to get what he wants ?
Code:
while read line; do |
Or you could just do it all in awk:
Code:
#!/usr/bin/awk -f |
Excellent, many thanks for the help everyone.
|
All times are GMT -5. The time now is 02:48 PM. |