LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to cd in a script function? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-cd-in-a-script-function-637449/)

subhrajyotibal 04-24-2008 01:33 AM

How to cd in a script function?
 
I am using ksh.
I hve written a script fun.sh
in this script i have written 3 functions
1)date_time
2)calender
3)delete_file
then in the same fun.sh script ihave written a case structure
in that
for choice 1 it calls date_time
for 2 calls calender
and for 3 calls delete_files

in the fuction delete_files i have done a cd.
my prob lem isthat when iam executing the script the cd is not happenning.

acid_kewpie 04-24-2008 01:59 AM

is your script top secret? would be more useful to be able to actually see it...

subhrajyotibal 04-25-2008 01:52 AM

I have to Write a script to determine whether given command line argument ($1) contains "*" symbol or not, if $1 does not contains "*" symbol add it to $1, otherwise show message "Symbol is not required". For e.g. If we called this script ex4.sh then after giving ,
$ ex4.sh /bin
Here $1 is /bin, it should check whether "*" symbol is present or not if not it should print Required i.e. /bin/*, and if symbol Is present then Symbol is not required must be printed. Test your script as
$ ex4.sh /bin
$ ex4.sh /bin/*


i have wrtten yhe script like this:
#! /bin/ksh
#
echo "$1" >t1
grep "\*" t1
if [ $? -ne 0 ];then
echo "required * in the $1"
else
echo "symbol is not required"
fi

but when im executing the script like
./q4.ssh /bin/*

it doent work properly


All times are GMT -5. The time now is 05:37 AM.