question about limiting the display from the ls command


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers question about limiting the display from the ls command
# 1  
Old 09-05-2003
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?
# 2  
Old 09-05-2003
Does your system has a head(1) command? You can pipe the output to head(1) to print the first few number of lines.
# 3  
Old 09-05-2003
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.
# 4  
Old 09-06-2003
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?
# 5  
Old 09-06-2003
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.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Solaris

Display Message Question

I'm have a script that I am creating and I want the dmesg command to only show output for the current day and the day before. What would be the command to make this work? Thanks (8 Replies)
Discussion started by: MattyJ2009
8 Replies

2. Shell Programming and Scripting

Limiting the Script

Greetings. I have script to monitor the disk space of folder it runs every 17 min with help of cron. It sends email when disk size reaches to 85 %. Now the issue is that it continousely generates email until we clear some space in that folder. Is it possible to restrict the Script to send only... (14 Replies)
Discussion started by: manju98458
14 Replies

3. Solaris

Limiting Connections from a single IP

I'm looking for a way to limit connections to a Solaris 10 box from any single IP. The problem is that I've had more experience doing this with IPTables on Linux, rather than with IPFilter, which I've found to be somewhat feature-poor. I hope there is some way to do this using IPFilter, I've... (2 Replies)
Discussion started by: spynappels
2 Replies

4. HP-UX

Limiting SFTP Users While Not Limiting Regular Users?

Hi, I have searched the web and have come back with nothing that is satisfactory for what I require. SFTP is my corporations new file transfer standard. What I require is a method to lock down SFTP users to their directory (they may go to sub directories) while not restricting regular users. ... (2 Replies)
Discussion started by: Emancipator
2 Replies

5. UNIX for Dummies Questions & Answers

SSH keys and command limiting ...

Hi, I've just been trying to setup so that server1 can ssh into server2 and execute a limited set of commands only without password login. I want it also to be able to login with a password if no command given at all though (bit I'm stuck on). I have got this almost working with authorized_keys... (1 Reply)
Discussion started by: moomain
1 Replies

6. SuSE

inconsistent ls command display at the command prompt & running as a cron job

Sir, I using the following commands in a file (part of a bigger script): #!/bin/bash cd /opt/oracle/bin ls -lt | tail -1 | awk '{print $6}' >> /tmp/ramb.out If I run this from the command prompt the result is: 2007-05-16 if I run it as a cron job then... (5 Replies)
Discussion started by: rajranibl
5 Replies

7. Shell Programming and Scripting

display and output...question

Hi, I have a small question about the value cannot display correctly: MSG=log fruit=apple print "No $fruit in the store" > "$MSG/fruit_message.txt" output: No $fruit in the store should be: No apple in the store AND $MSG/fruit_message.txt ----------> cannot find the... (5 Replies)
Discussion started by: happyv
5 Replies

8. Solaris

Exporting X display question

I have a sun box i can connect to using exceed in broadcast or query mode. I have been using passive mode to call up just a few apps, xcalc for example. How do i get the solaris 9 user login screen using passive mode? is it dtlogin or something that im should run frmo the shell? (0 Replies)
Discussion started by: BG_JrAdmin
0 Replies

9. UNIX for Dummies Questions & Answers

Limiting access

Hi, I'm new to linux and unix, and i have couple of problems: 1) how can i limit the access for a user, for example, i created a user, and i want that this user will be able to be only in one directory, and will see only the files i want him to. 2) I have a domain name, and i want that every... (4 Replies)
Discussion started by: misha
4 Replies
Login or Register to Ask a Question