Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've placed a file in the location


The script is placed in the location


From this location (/usr/local/bin/file_load/load_data), how can I access the file (file_1) which is placed in another location (/tmp/parent_dir/child_dir/file_1) from within the script?

share|improve this question
You do not actually ask any question. Try to state more clearly what exactly is your issue, and give a code sample if it applies. – Daniel Andersson Jun 20 '12 at 13:27

Do you want the shell script to receive the path of the file on the command line? Something like this would help:

cat $file

You can then call the script like this:

 /usr/local/bin/file_load/load_data /tmp/parent_dir/child_dir/file_1

which will output the file.

share|improve this answer
Giridharan: I'm running a script which needs to access files placed in a location other than the location of the corresponding script. To be precise, the files are in one location while the script that access the files are in another location. My question is how to access those files from within the script? When I give the absolute path in the script to refer to the location ('/tmp/parent_dir/child_dir/file_1'), it throws an error saying '/parent_dir/tmp: No such file or directory' – Giridharan Jun 20 '12 at 13:57
Can you show us the part of the script where you use the path to the file? The error message doesn't make much sense (parent_dir and tmp have switched positions?). – Kenneth Hoste Jun 20 '12 at 14:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .