Logo 
Search:

Unix / Linux / Ubuntu Articles

Submit Article
Home » Articles » Unix / Linux / Ubuntu » Homework HelpRSS Feeds

Write a shell script that takes a file names as a argument and deletes this file from every directory above the present working directory.

Posted By: Rambert Fischer     Category: Unix / Linux / Ubuntu     Views: 4163

Write a shell script that takes a file names as a argument and deletes this file from every directory above the present working directory.

Code for Write a shell script that takes a file names as a argument and deletes this file from every directory above the present working directory. in Unix / Linux / Ubuntu

if [ $# -eq 0 ]
then
        echo "pass the file name"
        exit
fi
fl=$1
ch=1
h=/home

while [ $ch -eq 1 ]
do
        cd ..
        p=`pwd`
        echo "$p/$fl"
        rm `echo "$p/$fl"` 2> /dev/nullif [ $p = $h ]
        then
                ch=0
        fi
done
  
Share: 



Rambert Fischer
Rambert Fischer author of Write a shell script that takes a file names as a argument and deletes this file from every directory above the present working directory. is from Frankfurt, Germany.
 
View All Articles

Related Articles and Code:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!