I am trying to run a script that uses awk. There is no error it seems, but it doesn't create the file that I want. This is the script:
#!/bin/bash
echo "Number of domain:"
read number
echo "Domain name:"
read domain
more "file.txt" | awk '$2=='$domain' {print $1, "1.0"} $2!='$domain' {print $1,"-1.0"}' >"$number_domain.txt"
echo "DONE"
Basically, I want to create a document leaving all $1 that are, and changing $2, if it is $domain, write 1.0, else -1.0.
I am confused about how you can write the text with " " or ' ' and the awk ' ' and " ".
Best Answer
The last item on this line
is probably intended to be
corresponding to the two variables which your script reads. It would be nice if your script also ensured that the variables are not empty strings. If they are empty, then the awk script will misbehave.