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

How would you replace the n character in a file with some xyz?

7 Answers  


How to initialize a directory size to a variable??

2 Answers  


Give some situations where typing error can destroy a program?

0 Answers  


What is the lifespan of a variable inside a shell script?

0 Answers  


Why is shell scripting important?

0 Answers  


What are the four fundamental components of every file system on linux?

0 Answers  


What is the fastest scripting language?

0 Answers  


What is the way to do multilevel if-else's in shell scripting?

0 Answers  


Hello all, This is my assignment on shell scripting, can anyone help me regarding this ? Create a shell script which connects to the database In second shell script include the first script for the DB connection Create a table (PRADEEP_DATA) with 2 columns (name, value) In Third shell script include the first script for the DB connection And insert/delete the values from the Table, by accepting input from the user This functionality should be a menu driven Program: 1) Insert to the database a. Name b. value 2)Delete from the database a.Name b.value Exception handling needs to be taken care.

0 Answers   Cap Gemini, Wipro,


Explain about return code?

0 Answers  


What does echo mean in scripting?

0 Answers  


Is it possible to substitute "ls" command in the place of "echo" command?

0 Answers  


Categories