Q1 : $cat << EOF > script
{ totalsize += $4 }
END { print “You have a total of “totalsize /
“ bytes used across “NR” files.”
}
EOF
$ls -l | awk -f script
Error Message:
awk: script: line 1: syntax error at or near }
awk: 2: unexpected character 0xe2
Q2 :
Definition of these two:
tty7
pts/0
Q3 :
$awk -F: ‘{ if (length($1) == 2) print $0 }’ /etc/passwd | wc –l }
what does this mean?? It uses the /etc/passwd file for input and has a colon as the field delimiter (the-F:).
error message: awk: line 1: syntax error at or near length
Q4:
cat << EOF > awkscript
{
count[length($1)]++
}
END {
for (i=1; i < 9; i++)
print “There are “ count[i] “ accounts with “ i “ letter names.”
}
EOF
$awk -F: -f awkscript < /etc/passwd
Q5: even by typing such a simple line I get the following error:
$awk -F: ‘{if lenght($1) > 1 print $0}’ < /etc/passwd
awk: line 1: syntax error at or near lenght