Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 11-19-2014, 01:15 PM   #1
Registered: Aug 2009
Posts: 349

Rep: Reputation: 16
putting a path into a varaible and change directory

I have this script that just unzips a few files.
I have labeled this directory in the "basename"
name space. Which is great becuase I don't have to
write out the whole thing in the line every time I
reference the path. However the script does not change to the
directory. The "cd to $basename" does not work.
the script does not switch to the basename direcotry after it is done .
    wrapper_date=$(/bin/date +%Y%m%d)


    gunzip "$base_path$wrapper_date$file1.gz"
    gunzip "$base_path$wrapper_date$file3.gz"
    #does this not go to the next command unless the gzip is done.
    cd $basepath
Old 11-19-2014, 01:20 PM   #2
Registered: Apr 2012
Distribution: Gentoo
Posts: 570

Rep: Reputation: 133Reputation: 133
$basepath undefined.
cd $base_path
Old 11-19-2014, 03:21 PM   #3
Registered: Aug 2002
Posts: 16,025

Rep: Reputation: 1850Reputation: 1850Reputation: 1850Reputation: 1850Reputation: 1850Reputation: 1850Reputation: 1850Reputation: 1850Reputation: 1850Reputation: 1850Reputation: 1850
Could be a typo but the shell does not inherit a program's environment (actually it is a child process) even though you change directories from within the script once it exists your back where you started.

Last edited by michaelk; 11-19-2014 at 03:33 PM.
Old 11-19-2014, 11:40 PM   #4
Registered: Aug 2010
Location: Netherlands
Distribution: Kubuntu, Debian, Suse, Slackware
Posts: 317

Rep: Reputation: 73
Or you can use pushd/popd to change directories and return to the stored directories when you're done.



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
block the users to change directory path in ftp sudheer1243 Linux - Newbie 2 07-02-2014 11:56 PM
Putting cc Compiler into $PATH Davethesnake Linux - Newbie 6 10-31-2010 05:08 PM
how to change extensions for many files in other directory path FahadOnline Linux - Newbie 6 07-17-2008 02:40 AM
Mozilla Directory Path Change: go_sooner Linux - Software 4 06-11-2005 01:21 AM
How to change the path of the current directory ? ndha Linux - General 7 12-03-2003 11:05 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:09 AM.

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