The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 05-27-2009
sysgate's Avatar
sysgate sysgate is offline Forum Advisor  
Unix based
  
 

Join Date: Nov 2006
Location: Bulgaria
Posts: 1,323
Well, this is partially true. You may get confused when executing the script from another location or you may need to navigate back to the original folder.
You should rather use the full path to the file, i.e. 'cat /home/bob/test.txt'
Example :
Code:
cd /folder/test/
cat file1.txt
cd - 
# return to the last folder, variable kept in ENV as OLDPWD.
# or 
cd /home/bob/test/firstfolder/secondfolder/
cat somefile.txt

You can simply avoid all those 'cd' commands by just using the full path to the file.