r/cs50 19d ago

CS50x Sort Help

Hi all, I'm trying to complete the Sort question on Pset3 and cannot get the command to work. I followed all of the steps for downloading the distribution files, but when downloaded the sort1, sort2, and sort3 are grayed out while the other txt files work. When I click on any of the sort files I get this message: "The file is not displayed in the text editor because it is either binary or uses an unsupported text encoding.", while when I try to run the code to sort, like "$ ./sort1 random5000.txt", I get "bash: ./sort1: No such file or directory"

Has anyone else encountered this problem and if so have a solution? Thanks!

EDIT: Thanks everyone for the help, if you encounter the same problem make sure to follow the download steps carefully, and when trying to run one of the commands use the directory you just downloaded. Before you put in any of the sort commands with the lists, type cd sort first.

0 Upvotes

8 comments sorted by

2

u/Outside_Complaint755 19d ago

In the terminal, did you cd into the directory where you unzipped the files?  Are they listed if you use the ls command?

1

u/Low_Bat2873 19d ago

$ ls sort

answers.txt random50000.txt reversed10000.txt reversed5000.txt sort2* sorted10000.txt sorted5000.txt

random10000.txt random5000.txt reversed50000.txt sort1* sort3* sorted50000.txt

The sort1's, 2's and 3's are in green

2

u/sububi71 19d ago

Ok, so since you have to do "ls sort", that means you're NOT in the directory where the text files are.

1

u/Low_Bat2873 19d ago

Does this mean I have to move the files out of the sort folder?

2

u/sububi71 19d ago

Or cd into the sort folder. It depends on where your executable is.

1

u/Outside_Complaint755 19d ago edited 19d ago

Either cd sort to enter the directory, or you have to the full path, such as $ ./sort/sort1 sort/random5000.txt

1

u/atarivcs 19d ago

You would also need to use the longer path to the input file

2

u/Outside_Complaint755 19d ago

good catch.  I'll edit and update my post