![]() |
|
|
|
|
|||||||
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Help required regarding Unix Signal | k_bijitesh | UNIX for Advanced & Expert Users | 9 | 01-08-2007 11:44 PM |
| UNIX Internals, Help required... | digdarshan | High Level Programming | 4 | 08-04-2005 12:54 AM |
| Coding Standard For Unix Shell Scripting!!! | Omkumar | Shell Programming and Scripting | 1 | 03-28-2005 09:19 AM |
| UNIX PATH info required PLEASE HELP (I'm new to unix) | akitachi | UNIX for Dummies Questions & Answers | 1 | 05-10-2002 11:37 AM |
| Unix Coding Standards | himanshu_s | UNIX for Dummies Questions & Answers | 3 | 12-06-2001 12:34 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
Hi!
Suppose I am at a location xyz:/abc1/abc2/abc3 Is it possible to move to another location xyz:/mnl1/mnl2/mnl3 by some coding within a script? |
| Forum Sponsor | ||
|
|
|
|||
|
Maybe you are confused by the fact that if you put a cd command into a file and then execute the file your working directory doesn't change.
This is because the script is executing in a subshell that inherits your current environment. When the script finishes any changes it made to its own environment are lost with it. The answer is to execute the script within your current environment rather than in a subprocess. This is called sourcing the script due to the command "source" used to accomplish this in the csh. It's still called sourcing the script even though the syntax is simply to use a dot in ksh or bash. So, if a file called script contains a cd command, then . script will change your current working directory. |
|
|||
|
Quote:
/abc1/abc2/abc3 and you want it to be /mnl1/mnl2/mnl3 then enter the command cd /mnl1/mnl2/mnl3 This bit of your question "by some coding within a script?" is what I was trying to answer but I'm now assuming that you didn't know you could change directories without using a script. |
| Thread Tools | |
| Display Modes | |
|
|