0

I'm trying to print out all the words in misspelled (which is "rools hatte" ).

But I keep being given the error

sed: -e expression #1, char 17: unterminated `s' command

I've tried different ways I've found on this website and elsewhere, but I always get this error regardless.

linecount="$(wc -l < misspelled)"
echo -e "MISSPELLED: \t\t\t CORRECT:"
for NUM in 'seq $linecount'
do
    sed "${NUM}q;d" misspelled
done
1

You have the wrong type of quotes around seq $linecount. You have single quotes, which make the whole phrase get treated as a single string. If you want to execute it and use the results you want backticks:

`seq $linecount`

or, better now, use the $(...) syntax which does the same

for num in $(seq $linecount)

or you could do it without the other program at all:

num=1
while [ "$num" -le "$linecount" ]; do
    ...
    ((num=num+1))
done

If you're trying to print out the first N lines of the file though you should probably use just head:

head -n "$linecount" misspelled
  • Hey thanks for all the help. I had one more question. I wanted the output formatted like in a way that woul dhave the misspellings under the MISSPELLING text. Is there an easy way to do that? – MrDaveForDays Oct 4 '16 at 0:31
  • I finally got it, thank you so much for the help! Youre the best! – MrDaveForDays Oct 4 '16 at 0:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.