Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm logged into an IP Phone running MontaVista with a very stripped down BusyBox binary (by stripped down, I mean the OEM has removed almost all of its functionality, except the basics like cat, ls etc).

I'm doing an ls -l on a directory and there are thousands of files. I need to be able to pause the file list on the end of each page of results.

Normally I would do this with ls -l|more or even ls -l|less but of course, more and less are not present on this phone.

Are there any other low-level ways of making ls paginate? My only other option is to write the output to a file and then tftp it off the server and open it on a proper computer, but this is a very roundabout (and slow) method of doing it.

share|improve this question
add comment

1 Answer 1

up vote 4 down vote accepted

If you are accessing the device through a terminal, you can use GNU Screen to connect; you can then use Screen's scrolling to see the output.

If the system has vi installed, you can try outputting the command to a file and reading it with vi.

If those don't suffice, you can make a bash script to output a screen's worth then pause.

for line in $(ls -l); do
  echo "$line"
  i=$((i+1))
  [ "$i" = 50 ] && read && i=0
done

This prints 50 lines and waits for you to press enter before printing the next 50.

share|improve this answer
    
Perfect - that little script worked brilliantly. Slow, but that's OK as I need to scan the files by eye anyway. –  Mark Henderson Feb 15 '11 at 2:44
    
(Ah, I didn't see the sleep command in there, no wonder) –  Mark Henderson Feb 15 '11 at 2:46
    
Yeah - originally, I had a read there. It took a little bit to figure out why it wasn't working. You might be able to use read < /dev/console. –  Shawn J. Goff Feb 15 '11 at 3:22
    
Okay, edited to be better. –  Shawn J. Goff Feb 15 '11 at 3:46
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.