Using a .txt thats in a directory without specifying directory
Linux - NewbieThis 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!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
My problem is MyDataReader1.txt has to be in a directory named data. Is their a way you can add to the .bash_profile (im guessing) to look into directory "data"? Thats what i did with classpath for directory "classes"
You should be aware that your prof might be a LQ user/visitor too and might not appreciate you asking us to do your homework for you. We would be glad to point you to errors in whatever you tried and is failing/erroneous but we will not provide you with ready made solutions. You'll learn a lot more when doing it yourself.
Looking forward to your participation in the forums. Have fun with Linux.
He's going to run the application from my base directory which has a subdirectory data though. The only way i could run that line and make it work is when i add data/MyDataReader1.txt instead of just the filename
I tried that before (without $HOME/bin though) now i have:
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
# User specific environment and startup programs
export USERNAME BASH_ENV PATH
-bash: MyDataReader1.txt: No such file or directory
This clearly mentions that you are reading something from a file from the current directory.
What best you can do is to modify the program to automatically pick the file from the data directory.
So run only java applications.TestMyDataReader.
or "java applications.TestMyDataReader MyDataReader1.txt" -- in this way you are accepting the file name as a parameter. Then look for the file name under the data directory and open it and process it.
Exactly. You're explicitly directing the input with the "< MyDataReader1.txt" part so your program can't override that. The only thing you could do is have your program ignore that input on STDIN and just use the data/MyDataReader1.txt path hard-coded in. It's dirty but that's the only way to bypass that explicit redirection that I can think of.
Technically Yes.. It will work. But everytime the user should create a symlink to the file if the file name is changing..
If the file name is not changing, why don't the program directly process the file, instead of accepting it as an input or getting the contents from it using a redirection. ?