LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-24-2008, 02:33 AM   #1
subhrajyotibal
LQ Newbie
 
Registered: Apr 2008
Posts: 2

Rep: Reputation: 0
Thumbs up 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.
 
Old 04-24-2008, 02:59 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
is your script top secret? would be more useful to be able to actually see it...
 
Old 04-25-2008, 02:52 AM   #3
subhrajyotibal
LQ Newbie
 
Registered: Apr 2008
Posts: 2

Original Poster
Rep: Reputation: 0
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Split function (bash script) NiM Programming 11 03-10-2012 07:53 AM
sh script: problem with return value in function jhwilliams Linux - Software 1 06-20-2007 12:47 PM
return value of function in script ramesh_manu Red Hat 1 02-18-2007 02:05 PM
shel script/search for a function shyamdey Programming 2 08-30-2006 08:47 AM
search function (bash script) LYK Programming 2 05-27-2004 11:51 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:32 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration