question about limiting the display from the ls command

hey guys im rly new to unix. im attempting to list the 5 largest files in a directory.

so i got this far...

ls -lR | sort -r

and this lists all files by filesize, how can i limit this to only the 5 largest?

Does your system has a head(1) command? You can pipe the output to head(1) to print the first few number of lines.

Hmm, I'm not sure how that would list files by filesize, Aesop...

I would use something like ls -lR | sort -rk 5 and then pipe the output to the head command as suggested by cbkihong.

the writeup doesnt mention anything about head, just says you may want to use pipe or sort. if its not possible to do without head, then how what is the syntax for that?

On my system, I can use this to output the max. 5 files:

ls -lS | head -n 5

In any case, you may check up the syntax from man pages. Type "man head" and you should see.