Help run ls command along with find command


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Help run ls command along with find command
# 1  
Old 08-20-2008
Help run ls command along with find command

Hi,
I want to run ls -lrt command along with find command. I want to get the list of files with timestamp, owner, group and permissions for the files larger than 1024k. I tried the below command, but it displays only the file names.

ls -lrt | find . -name "*.*" -size +1024k -print


Any help

Thanks
# 2  
Old 08-20-2008
Code:
find . -name "*.*" -size +1024k -print | xargs /bin/ls -lrt

- nilesh
# 3  
Old 08-20-2008
Something like this?

Code:
find . -name "*.*" -size +1024k -exec ls -lrt {} \;

Regards
# 4  
Old 08-20-2008
Nilesh and Franklin

Thanks for your help.

Thanks
# 5  
Old 08-24-2008
Thank you too :)

Thank you too - I'm just becoming more familiar with Linux and I was looking for something like this off and on for awhile Smilie

oh btw - When you send in the -exec command with the ls -(options) command, why do you need to add the "{} \;"?
# 6  
Old 08-24-2008
Hi and welcome,

In the manpage of the find command there is an explanation of the -exec action and the use of {}.

Regards
# 7  
Old 08-24-2008
Quote:
Originally Posted by bztian
oh btw - When you send in the -exec command with the ls -(options) command, why do you need to add the "{} \;"?
The {} gets replaced with the found file's name, and the \; shows where the -exec command line ends, so you can continue to specify other options to find.
You could even have multiple -exec actions:

Code:
find . -type f -exec ls -l {} \; -exec touch {} \;

Without the \; how would you know where the first -exec command ends and we are back in find's command line proper again? The command you -exec could even be another find so looking for familiar options is not a good way to disambiguate; and besides, other programs than find have options like -type and -name too.

Having said that, -exec is usually the last thing you do, and the file name of the found file is usually the last thing in that command line, so it does seem a bit redundant in those cases. A common exception would be the mv command where the found file is usually the thing you want to move.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

How to use dsadm command to run command on multi lpars?

how to run a command, such as "ls -l core" from one lpar to check multi lpars if core file exist? or what way can do a command on all lpars from one lpar? Thanks (1 Reply)
Discussion started by: rainbow_bean
1 Replies

2. Shell Programming and Scripting

Script for telnet and run one command kill it and run another command using while loop

( sleep 3 echo ${LOGIN} sleep 2 echo ${PSWD} sleep 2 while read line do echo "$line" PID=$? sleep 2 kill -9 $PID done < temp sleep 5 echo "exit" ) | telnet ${HOST} while is executing only command and exits. (5 Replies)
Discussion started by: sooda
5 Replies

3. Shell Programming and Scripting

Need help! command working ok when executed in command line, but fails when run inside a script!

Hi everyone, when executing this command in unix: echo "WM7 Fatal Alerts:", $(cat query1.txt) > a.csvIt works fine, but running this command in a shell script gives an error saying that there's a syntax error. here is content of my script: tdbsrvr$ vi hc.sh "hc.sh" 22 lines, 509... (4 Replies)
Discussion started by: 4dirk1
4 Replies

4. Shell Programming and Scripting

Is command line invocation of gnome-terminal to run more than one command possible?

Hello, I am trying to learn how to pass something more than a one-command startup for gnome-terminal. I will give an example of what I'm trying to do here: #! /bin/bash # #TODO write this for gnome and xterm USAGE=" ______________________________________________ ${0##*/} run... (0 Replies)
Discussion started by: Narnie
0 Replies

5. Shell Programming and Scripting

Command to find the Memory and CPU utilization using 'top' command

Hi all, I found like top command could be used to find the Memory and CPU utilization. But i want to know how to find the Memory and CPU utilization for a particular user using top command. Thanks in advance. Thanks, Ananthi.U (2 Replies)
Discussion started by: ananthi_ku
2 Replies

6. UNIX for Dummies Questions & Answers

find command and run it

Hi guys, how would I find out if the command/script exists on the system ( HP-UX, Linux ) and if it does run it so it would display the output? lets say I can do which any-command and if it finds any-command I want to run it ... I can use echo $? to see what the which command... (2 Replies)
Discussion started by: mirusko
2 Replies

7. UNIX for Dummies Questions & Answers

Find command to run only in the base directory

Hi. I'm trying to get my find command to only search in the directory i tell it to, but i don't want it to search in the sub directories as well... For example, i have a /data/files/ and /data/files/old I want to search for all .sav files within /data/files but i don't want it to drill... (4 Replies)
Discussion started by: Stephan
4 Replies

8. UNIX for Dummies Questions & Answers

How to run multiple command in single command?

Dear Unix Guru, I have several directories as below /home/user/ dir1 dir2 dir3 Each directory has different size. I want to print each directory size (Solaris command du -hs .) Can you please guide me how to achieve this? Thanks Bala (2 Replies)
Discussion started by: baluchen
2 Replies

9. UNIX for Dummies Questions & Answers

command to run a command after 30 mins

how to schedule a command to run after 30 mins ? (3 Replies)
Discussion started by: gridview
3 Replies

10. Shell Programming and Scripting

I want to get the file which created the error when the find command was run

I want to get the file which created the error when the find command was run ? I am wrote a script to mail a list of files whose file size is ge than 0 and returns 0 but wen it finds a folder with only empty files it exits as 1. i need to modify it so that the return for this is also 0 (but it... (1 Reply)
Discussion started by: guhas
1 Replies
Login or Register to Ask a Question