LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 09-16-2006, 09:24 AM   #1
zefram
Member
 
Registered: Nov 2005
Distribution: Debian
Posts: 42

Rep: Reputation: 15
changing directory in bash (or other) script


Hi,

I have made a little a bash script, ment to change the current directory:

#!/bin/sh
d=$( date +%Y.%m.%d)
cd /_g/$d

I find however, that it only changes the directory within the script, and at the end of the script the location doesn't change.

I guess i need to export something for this to work?
 
Old 09-16-2006, 10:32 AM   #2
berbae
Member
 
Registered: Jul 2005
Location: France
Distribution: Arch Linux
Posts: 540

Rep: Reputation: Disabled
suppress the first line of your script:
d=$( date +%Y.%m.%d)
cd /_g/$d
And launch it using the source command:
source ./name_of_your_script
or
. ./name_of_your_script
rather than
./name_of_your_script
 
Old 09-16-2006, 10:41 AM   #3
zefram
Member
 
Registered: Nov 2005
Distribution: Debian
Posts: 42

Original Poster
Rep: Reputation: 15
thanx. works fine.
 
  


Reply

Tags
bash



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash script to strip a certain directory out of directories in a directory? rylan76 Linux - General 3 08-29-2006 11:35 AM
BASH script for changing screen resolution ylikone Programming 10 05-11-2006 05:11 AM
Changing user in bash script. r3gan Linux - Security 3 03-15-2006 11:27 AM
changing path from a bash script ggeeoo Linux - Newbie 7 01-04-2006 06:35 PM
changing bash login working directory Samsara Linux - Software 5 05-30-2004 05:03 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 07:00 AM.

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
Open Source Consulting | Domain Registration