How to initialize a directory size to a variable??

Answers were Sorted based on User's Feedback



How to initialize a directory size to a variable??..

Answer / damodar rao

#!/bin/bash
echo 'enter the directory name with path Ex: /home/damoar: ';
read $x;
$size = `du -h $x`;
echo 'size of a given directory $x is : `$size` ';
:wq

Is This Answer Correct ?    3 Yes 0 No

How to initialize a directory size to a variable??..

Answer / pushkar

if [ -d $var ] ;then
rm -rf $var
fi
mkdir $var

Is This Answer Correct ?    1 Yes 4 No

Post New Answer

More Shell Script Interview Questions

I want to read all input to the command from file1 direct all output to file2 and error to file 3, how can I achieve this?

1 Answers  


What is the need of including script interpreter in your shell script?

2 Answers  


wats the she bang statment with syntax?

3 Answers  


How do I stop script errors?

0 Answers  


How to calculate the number of passed arguments?

0 Answers  






How to replace following lines, catch (DAOException e) { objLogger.error(this.getClass () + "addUpdateIssues() " + e); throw new BOException(5122); } catch (BOException e) { objLogger.error(this.getClass () + "addUpdateIssues() " + e); throw e; } catch (Exception e) { objLogger.error(this.getClass () + "addUpdateIssues() " + e); throw new BOException(5122); } Needs to be changed in to, catch (DAOException e) { AppException.handleException (null, null, e, null, null, null, "BOException", this.getClass() + "addUpdateIssues() ", null, null, null, null, null, null, null, null, 5122); } catch (BOException e) { AppException.handleException (null, null, null, e, null, null, "BOException", this.getClass() + "addUpdateIssues() ", null, null, null, null, null, null, null, null, 0); } catch (Exception e) { AppException.handleException (null, null, null, null, null, e, "BOException", this.getClass() + "addUpdateIssues() ", null, null, null, null, null, null, null, null, 5122); }

0 Answers   Wipro,


Hi, I want to practise Unix korn shell scripting which i learnt 2 yr bfr. plz suggest software i can use to practise.

1 Answers  


How do I debug a shell script?

0 Answers  


How do you create a shortcut in linux?

0 Answers  


Why is the use of shell script?

0 Answers  


Where is bash history?

0 Answers  


What are the 4 basics of OOP?

1 Answers   Amazon, Infosys,


Categories