LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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, 06:39 AM   #1
battles
Member
 
Registered: Apr 2014
Distribution: Debian GNU/Linux 7.5 (wheezy)
Posts: 258

Rep: Reputation: Disabled
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, 07:52 AM   #2
battles
Member
 
Registered: Apr 2014
Distribution: Debian GNU/Linux 7.5 (wheezy)
Posts: 258

Original Poster
Rep: Reputation: Disabled
Found it:

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


Reply



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:12 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
Open Source Consulting | Domain Registration