Eliminating output?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Eliminating output?
# 1  
Old 12-01-2009
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... Smilie
# 2  
Old 12-01-2009
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  
Old 12-01-2009
Code:
find $lr_choice1 -type f -exec ls -s {} \; |sort -nr |head -"$lr_choice2"

# 4  
Old 12-02-2009
excellent that works


cheers!!!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Eliminating duplicate lines

Hello, I am trying to eliminate lines where column #1 is duplicated. If it is a duplicate, the line with the greater value in column #2 should be deleted: file.dat 123 45.34 345 67.22 949 36.55 123 94.23 888 22.33 345 32.56 Desired ouput 123 45.34 949 36.55 888 22.33 345 32.56... (4 Replies)
Discussion started by: palex
4 Replies

2. Shell Programming and Scripting

First zero is eliminating in the awk command

I am using something like this in my code nawk 'BEGIN{OFS=FS="|"} {$15='$CalaMig'} {print}' filename actually value of $CalaMig=01234 But its replacing as 1234 in the 15th postion.Its not taking the first zero. can some one help here (1 Reply)
Discussion started by: saj
1 Replies

3. Shell Programming and Scripting

Need help with eliminating newlines with Perl

Good morning, I need some help with getting rid of newlines with the output from a MYSQL query and putting the information into the right format that I need. Here is the script as it is today: #!/usr/bin/perl my $uda = system("/opt/incontrol/mysql/bin/mysql -u root -ppassword... (2 Replies)
Discussion started by: brianjb
2 Replies

4. Shell Programming and Scripting

Eliminating space constraint in grep

here in the below code just a space between 'Info' and '(' is showing that the patter doesnt match... echo "CREATE TABLE Info (" | grep -i "CREATE TABLE Info (" | wc | awk -F' ' '{print $1}' 1 echo "CREATE TABLE Info (" | grep -i "CREATE TABLE Info (" | wc | awk -F' ' '{print $1}' 0 ... (9 Replies)
Discussion started by: vivek d r
9 Replies

5. Shell Programming and Scripting

Eliminating differences in two files

Hello, I'm having trouble to read two txt files, they have employee records line by line, I need to do the reading of a file that is old and compare it with the new base in the new file, deleting the lines in old file, then add the new file data from the old file and write to the database manager.... (5 Replies)
Discussion started by: selmar
5 Replies

6. Programming

Eliminating a row from a file....

I have a file like 1 0 2 0 3 1 3 0 4 0 6 1 6 0 . . . . . . i need to eliminate values 3 0 and 6 0 in the same way there are such values in the whole file....but 3 1 and 6 1 shuld be present... (2 Replies)
Discussion started by: kamuju
2 Replies

7. Shell Programming and Scripting

After eliminating then save as a string

Hello, I am using HP-UX B.11.23 U ia64 2591592275 unlimited-user license I am trying to write a sh script on my own system to pass string of word as one parameter The format of the string will be the same But the content after : will be changed each time If you manage to have this as $*... (7 Replies)
Discussion started by: fahad.m
7 Replies

8. Shell Programming and Scripting

Eliminating duplicates from the who command

I am trying to show how many users are logged into one of my systems. Using who -q it gives me a user count, but some users are logged in multiple times. Is there any easy parameter that I can use to ignore/eliminate these duplicates?? Thanks (9 Replies)
Discussion started by: mikejreading
9 Replies

9. UNIX for Dummies Questions & Answers

Eliminating CR (new lines) from a file.

Hi all, I made a C++ program in dos (in dev-C++) and uploaded it on Solaris box. On opening that file with 'vim' editor i found that there is some extra new lines after each written code line. I tried to find out is the file is in dos or in unix format, with 'file' command,and i got "<file-name>.h:... (4 Replies)
Discussion started by: KornFire
4 Replies

10. HP-UX

Eliminating characters between two expressions

Hi I have to eliminate all characters between ^ and a space in a file. Following lines - Test ^ H^@^@^@^@^@^@^B^VDM-BM-$|M-^_M-F^AM- File1 Test^H^@^@^@^@^@^F^A^X^@^SM-s^TM-3M-G^A File2 Should be printed as below Test File1 Test File2 I used sed '/^/,/ /d' command, but it is not working.... (1 Reply)
Discussion started by: arsheshadri
1 Replies
Login or Register to Ask a Question