Question: Basically I need to run a Unix script to find all folders in the directory /fss/fin, if it exists; then I have tar it and move to another directory /fs/fi.

This is my command so far:

```
find /fss/fin -type d -name  "essbase" -print

```

Here I have directly mentioned the folder name `essbase`. But instead, I would like to find all the folders in the `/fss/fin` and use them all.

How do I find all folders in the `/fss/fin` directory & tar them to move them to `/fs/fi`?

Clarification 1:

> 
> Yes I need to find only all folders in the directory `/fss/fin` directory using a Unix shell script and tar them to another directory `/fs/fi`.
> 
> 
> 

Clarification 2:

> 
> I want to make it clear with the requirement. The Shell Script should contain:
> 
> 
> 1. Find all the folders in the directory `/fss/fin`
> 2. Tar the folders
> 3. Move the folders in another directory `/fs/fi` which is located on the server `s11003232sz.net`
> 4. On user requests it should untar the Folders and move them back to the orignal directory `/fss/fin`
> 
> 
>

Answer: 
here is an example I am working with that may lead you in the correct direction

```
BackUpDIR="/srv/backup/"
SrvDir="/srv/www/"
DateStamp=$(date +"%Y%m%d");

for Dir in $(find $SrvDir* -maxdepth 0 -type d ); 
do
    FolderName=$(basename $Dir);
    tar zcf "$BackUpDIR$DateStamp.$FolderName.tar.gz" -P $Dir
done

```
This should do it:

```
#!/bin/sh

list=`find . -type d`

for i in $list
do
    if [ ! "$i" == "." ]; then
        tar -czf ${i}.tar.gz ${i}
    fi
done

mv *.tar.gz ~/tardir

```