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
slm
  • 369,824

1 Answers1

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 '{}' +
slm
  • 369,824
  • @DanielDharmaraj - everyone has to start there, stick w/ it, it gets easier. Please mark this as accepted if you're all set. – slm Aug 03 '18 at 05:49