LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 07-19-2014, 07:39 AM   #1
battles
Member
 
Registered: Apr 2014
Distribution: Debian GNU/Linux 7.5 (wheezy)
Posts: 231

Rep: Reputation: 5
Symbolic referencing current folder


I need to be able to place some scripts in any folder and run them with a cron. Now I am hard coding the path into each file the script creates. If this is not done, the files will end up in the root folder due to the cron execution. What I need is a symbolic reference that I can put before each file I create that will force the files to be placed into the current script's folder. Something equivalent to ./ in Windows.
Thanks
 
Old 07-19-2014, 08:52 AM   #2
battles
Member
 
Registered: Apr 2014
Distribution: Debian GNU/Linux 7.5 (wheezy)
Posts: 231

Original Poster
Rep: Reputation: 5
Found it:

filePath=${0%/*}
cat $filePath/test.txt
 
  


Reply


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
Issues Uploading via Apache to Symbolic Linked Folder asketchyfish Linux - Server 4 09-14-2012 03:12 PM
MyLQ, subscription folder, empty current folder fails with more than 100? threads zhjim LQ Suggestions & Feedback 2 06-08-2012 12:14 PM
Symbolic links to remote ftp folder HRCerqueira Linux - General 1 10-13-2007 07:43 PM
Compiling in any folder will install in current or correct folder ? anjanesh Fedora 4 05-10-2006 09:44 AM
When referencing a command, how far in depth can the symbolic link be followed? davidas Debian 2 04-12-2004 07:09 AM


All times are GMT -5. The time now is 11:28 AM.

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