0

I'm stuck with the script which I wrote on Bourne Shell.

Script:

echo "Who are you?"
read Individual
echo "Hello,$Individual"

echo "Where you want to go?"
read Path
grep -c "Path" file.txt
1

Sample data

$ mkdir -p dir{1..3}/dir{1..3}
$ tree dir*
dir1
├── dir1
├── dir2
└── dir3
dir2
├── dir1
├── dir2
└── dir3
dir3
├── dir1
├── dir2
└── dir3

9 directories, 0 files

The script

$ cat deletey.sh
#!/bin/bash

echo "Where you want to go?"
read Path
rm -fr $Path/*

Example run

$ ./deletey.sh
Where you want to go?
dir1
$

Result

$ tree dir*
dir1
dir2
├── dir1
├── dir2
└── dir3
dir3
├── dir1
├── dir2
└── dir3

6 directories, 0 files

Alternatives

Rather than use the rm -fr $Path/* you could opt to use a find instead:

finds dirs in $PATH & deletes
find $Path -mindepth 1 -type d -exec rm -fr '{}' +
same as above, runs from inside $PATH
find $Path -mindepth 1 -type d -execdir rm -fr '{}' +
  • @DanielDharmaraj - everyone has to start there, stick w/ it, it gets easier. Please mark this as accepted if you're all set. – slm Aug 3 '18 at 5:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.