Advertisement

02.25.2008 at 06:16PM PST, ID: 23192355
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

bash : files names having white space

Tags: bash
Hi Experts,

I am writing a bash script to find the largest 5 files in my account, the script works fine but it ignores files having white space in their names, I need someone to help me to fix this ,
this problem will occur in the code in this line:
 du  $line >> du.out;

If a file name is : my file.txt
the shell will try to execute this command :
du my file.txt >> du.out;

and this will not work ..I tried to have double quotation around the $line  but this also does not work

Thanks
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
#!/bin/sh
 
# this will list all files under the user home directory and store their names in files.txt  
 
   find $HOME -type f > files.txt
 
# files.txt will be opend and read line by line
# every file name will be passed to the "du" command to get its size
# the results will be stored in "du.out" file
 
   exec<files.txt
 
   while read line
   do
               du  $line >> du.out;
   done
 
# now we will sort the file using the sort command and store the result in "sort.out"
   
   sort +n du.out > sort.out
   
# now we will print the largest 5 files 
   tail -5 sort.out
 
# all temp files now will be deleted
   
   rm -f sort.out files.txt du.out
Start your free trial to view this solution
Question Stats
Zone: Programming
Question Asked By: Dr-Hussain
Solution Provided By: ozo
Participating Experts: 4
Solution Grade: A
Views: 51
Translate:
Loading Advertisement...
02.25.2008 at 06:21PM PST, ID: 20981175

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.25.2008 at 06:36PM PST, ID: 20981212

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.25.2008 at 06:43PM PST, ID: 20981228

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
20080236-EE-VQP-29 / EE_QW_2_20070628