The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to set echo on siegfried Shell Programming and Scripting 1 11-18-2005 01:56 AM
What does echo ^[[r do? hamsasal UNIX for Advanced & Expert Users 1 07-24-2005 01:14 PM
echo with \n whatisthis UNIX for Dummies Questions & Answers 3 05-18-2005 10:59 AM
echo ????? nguda UNIX for Dummies Questions & Answers 1 06-30-2003 04:02 PM
echo help bb00y High Level Programming 5 10-02-2002 08:53 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-22-2007
mainegate mainegate is offline
Registered User
  
 

Join Date: Aug 2007
Posts: 23
echo $0

I'm trying to figure out how to get the full path of a file. I found that typing:
echo $0 THEN I DRAG THE FILE INTO THE TERMINAL

That gets the full path but I can't figure out how to put that in a variable. I'm trying to take a file and drag it onto a script or automation and have it put that file's full path into a variable so that variable can go into my command line. This is what I have so far.

#!/bin/bash
name= $0
/usr/local/bin/ffmpeg -i "$name" -acodec mp3 -ab 192 -b 450kb -r 29.97 -s 320X240 -aspect 4:3 -ar 22050 "/Users/SteveComputer/Desktop/blah.mov"
echo $name

In reality I would like to control click on the file and have a variable get that full path but that is next. The $name above is the thing I want to be the full path of the file I drag onto the automation.

Thanks.
  #2 (permalink)  
Old 08-23-2007
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
If $0 is a file in the current directory, just prepend the current directory to it...
pathname=$PWD/$0
  #3 (permalink)  
Old 09-24-2007
royalibrahim royalibrahim is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 86
The echo "$0" gives the running script name with absolute path if started from another directory else it will just give "./<script_name>" where "." represents the current directory from where the script is running
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:52 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0