The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
grep unix.com with google



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Reply
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-01-2009
Registered User
 

Join Date: Oct 2009
Posts: 12
Eliminating output?

Hi Folks,

I am writting a shell script for general purpose use....

i have created a function like below:-


Code:
 
largest_file()
{
clear
tput cup 20 30
echo please enter the full directory path where you want to search:-
tput cup 21 30
read lr_choice1
tput cup 22 30
echo please enter the no of files you want to get:-
tput cup 23 30
read lr_choice2
cd $lr_choice1
find $lr_choice1 -type f -print | xargs ls -l | sort -k5,5rn | head -"$lr_choice2" > 
$script_dir/top_$lr_choice2_file_$date_var.txt
tput clear
tput cup 20 0
cat $script_dir/top_$lr_choice2_file_$date_var.txt
tput cup 25 0
echo press hit to continue
read hit
}

I call the function in a interactive shell script for displaying the n largest file in a directory..

Now when i call this function in a switch case programme.....i dont want to show the output generated by the find command .....i just want end results....

like if i call the function it should write only to the file and not stdoutput for operation so that user shouldn't know what happening...

your help is appreciated...
  #2 (permalink)  
Old 12-01-2009
Registered User
 

Join Date: Oct 2009
Location: St. Louis, MO
Posts: 78
I haven't tested but this should work:


Code:
find $lr_choice1 -type f -print | xargs ls -l | sort -k5,5rn | head -"$lr_choice2" > 
$script_dir/top_$lr_choice2_file_$date_var.txt 2>/dev/null


Last edited by pludi; 12-01-2009 at 02:17 PM.. Reason: code tags, please...
  #3 (permalink)  
Old 12-01-2009
Registered User
 

Join Date: Jun 2006
Posts: 468

Code:
find $lr_choice1 -type f -exec ls -s {} \; |sort -nr |head -"$lr_choice2"

  #4 (permalink)  
Old 12-02-2009
Registered User
 

Join Date: Oct 2009
Posts: 12
excellent that works


cheers!!!
Sponsored Links
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Eliminating paging space and interpreting memory utilization depam AIX 1 07-29-2009 07:30 PM
Eliminating duplicates from the who command mikejreading Shell Programming and Scripting 9 03-17-2009 01:12 PM
Eliminating CR (new lines) from a file. KornFire UNIX for Dummies Questions & Answers 4 01-29-2009 06:06 AM
Eliminating characters between two expressions arsheshadri HP-UX 1 06-26-2008 09:00 AM
Eliminating whitespaces during reading of a field. videsh77 Shell Programming and Scripting 4 12-13-2004 12:52 PM



All times are GMT -4. The time now is 02:19 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0