AWK in Putty

I am a beginner with shell script and AWK. I use PUTTY to write shell script.
Can I create new AWK script using vi command? I tried sample.awk. But everytime I open this file, the file does not retain anything I typed in.

Also, once AWK program is written, how do I execute it?

Thanks!

see man pages of awk

you can use any of your fav editor to write script.

if you want complete awk script, you should use "-f" option.

at your prompt, type:

awk -f myawkscript mytestfile

cat myawkscript
{print $0}

cat mytestfile
Hello World!

awk expects an input file to read.

alternatively, if you want to use awk as a part of your normal shell script,

## test scipt

echo "Hello World!" > mytestfile
### shell commands
## shell commands
awk '
### awk commands here
 {print $0} ' mytestfile ### awk ends here

### shell commands here

I think you're confused on what software you're using, PUTTY is not a text editor. Whatever its talking to might be running a text editor however.