#!/usr/bin/awk
userinput='Hello World!'
userinput=$userinput awk '
BEGIN {
s = ENVIRON["userinput"] "\n"
n = length(s)
while (1)
printf "%s", substr(s,int(1+rand()*n),1)
}'
Whenever I run above code I get following error.
awk: cmd. line:1: pass.awk
awk: cmd. line:1: ^ syntax error
#!/usr/bin/awk
awk '{
s = $0 "\n"
n = length(s)
while (1)
printf "%s", substr(s,int(1+rand()*n),1)
}'
awk: cmd. line:1: pass.awk
awk: cmd. line:1: ^ syntax error
I am getting same error both time. But, I am not getting any error when I write those code and run in terminal. It was little bit weird for me. Cause, I am new to awk. That may be a typo error I am not sure. I had saved the file name as pass.awk. Running this way awk pass.awk or, awk pass.awk hello
#!/usr/bin/awkshebang is not appropriate