My code is:
dnafile=$1 for seq in (fold -w3 $dnafile | uniq); do fold -w3 $dnafile | grep $seq | wc -l echo $seq echo '(new line)' done
I receive the error:
syntax error near unexpected token `('
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
It looks like you just want to count the number of unique lines resulting from
fold -w3 $dnafile. This can be done without a loop:
fold -w3 "$dnafile" | sort | uniq -c
sort would sort the lines of the output from
uniq -c would count the number of times each line occurs consecutively.
The output will be one line for each unique line in the
fold result prefixed with a number.
The syntax error comes from the fact that a command substitution (i.e. a construct that is replaced by the output of a command) needs to look like
$( ... ). I'm uncertain that inserting the missing
$ will actually make your code work though, as the shell will still split the resulting text on newlines and spaces, but since we don't know what the input data looks like it's difficult to speculate.
Having a sub-shell,
(...), in a for loop at that position is not allowed.