How to get first line of output from command line?

I'm running a find command that's returning multiple results, but I only need the first result. A bit of googling led me to the "read" command, but I couldn't figure it out, and the man page didn't prove too helpful.


Solution 1:

Enter your command (example: ls -l) then the head command with a pipe like so:

ls -l | head -1

note: there is documentation on this usage of 'head'

http://schillix.sourceforge.net/man/man1/head.1.html

 -n number    The first number lines of each  input  file  is
              copied  to  standard output. The number option-
              argument must be a positive decimal integer.

 -number      The  number  argument  is  a  positive  decimal
              integer  with  the same effect as the -n number
              option.

Shown here and as mentioned in the comments, this also works depending on your unix-based distribution:

 ls -l | head -n 1