grep "42$" questionnaires.txt > test42 | cut -d '/' -f 1 test42
doesn't do anything like you think it does.
The first part:
grep "42$" questionnaires.txt > test42
That writes the output of
test42. The output of that is nothing.
So that nothing then gets passed to
cut -d '/' -f 1 test42
Which is trying to read the file you're currently writing to, and sending the results to the screen. That's likely to be no output, and the file
test42 will have the data without the
cut being applied.
Now if you want the final file to just have the data you want to change the order:
grep "42$" questionnaires.txt | cut -d '/' -f 1 > test42
Now this means "get the results of the grep" and then "pass that through cut" and store the results of that in the file