0

This script worked perfectly for me last night but now has stopped with the error message "Invalid syntax" pointing at the dollar sign in LINES=$(cat 'ytZiele.txt')

#!/usr/bin/bash

LINES=$(cat 'ytZiele.txt')

for LINE in $LINES

do    
    echo $LINE
done
Hektor
  • 1,845
  • 15
  • 19
  • On my system bash lives in /bin/bash, i.e. use /usr/bin/env bash. What changed? If the script didn't then there is something in $LINES that trigger shell magic. – Allan Wind Feb 16 '21 at 01:43
  • Sorry, force of habit from python/perl. But using /bin/bash gives same error. – Hektor Feb 16 '21 at 01:45
  • Use one of these to make the loop safe https://stackoverflow.com/questions/4642191/read-line-by-line-in-bash-script – Allan Wind Feb 16 '21 at 01:45
  • Do you get the same error if remove everything after LINES? I.e. minimize the problem. If so, I would do a `od -a` of your script to make sure you don't have anything weird in it. You could also try an empty ytZiele.txt file. – Allan Wind Feb 16 '21 at 01:47
  • I get name 'LINES is not defined' – Hektor Feb 16 '21 at 01:50
  • OK thanks but I found the problem, running the bash script in python instead of bash...told you old habits die hard. Thanks for all your help, genuine thanks, sorry to waste your time. – Hektor Feb 16 '21 at 01:54
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/228774/discussion-between-allan-wind-and-hektor). – Allan Wind Feb 16 '21 at 01:54

1 Answers1

2

The error messages do not make sense, and op figured out that he was running the bash script with python.

Allan Wind
  • 23,068
  • 5
  • 28
  • 38