If it is a text file, you can process it directly
linenum = 1
lines = `cat filename`
for line in $ {lines}; do
if [$ [$ {linenum}% 2] -ne 0]; then
echo $ {line}
fi
linenum = $ [$ {linenum} +1]
done
Written like this $ fname
And your cat is also wrong. It is not a single quote, but a back quote. It is generally the one to the left of 1 on the keyboard, which means executing a shell command. It can also be replaced with $ ()
linenum = 1
read filename
lines = `cat $ {filename}`
for line in $ {lines}; do
if [$ [$ {linenum}% 2] -ne 0]; then
echo $ {line}
fi
linenum = $ [$ {linenum} +1]
done
However, the above code is actually problematic, that is, there can be no more tokens such as spaces in a line, otherwise an error will occur. The better method is the1231456method.