awk
hai,
i am searching a word in a file using awk. when it finds it will write $2 in other file. It is working perfectly. My question is if it does find that word i want to write that work in another file. How i will check whether the word is found or not? pls. let me know |
I'm not clear what you mean?
|
Quote:
Look in the other file. If it was found, it will be there; it is wasn't, it won't be. |
awk
Mr. Matthew Gates,
getSrc() { awk -F '|' -v abc=$1 '$1==abc {printf "%s\n",$2}' $2 >> $3 } The above code will run whenever getSrc function from shell script which will be called alongwith 3 parameters. $1 is a search string $2 is the input file $3 is the output file My question is if it finds match it will write into $3. If it doesn't find $1 in $2, i want to write $1 in some other file. How i will do this? KALYANA RAMAN. M |
awk supports similar re-direction facilities as the shell. So inside your awk program, you can write to named files, not just standard output:
Code:
# usage: getSrc pattern in_file found_out_file notfound_out_file |
All times are GMT -5. The time now is 07:12 PM. |