Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Getting filename with entire path without extension

Shell Programming and Scripting


Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 01-16-2011   -   Original Discussion by amicableperson
amicableperson's Unix or Linux Image
amicableperson amicableperson is offline
Registered User
 
Join Date: Jan 2011
Last Activity: 3 November 2012, 1:21 PM EDT
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Getting filename with entire path without extension

Hi Experts,

need one help.. m writing a shell script for which i need the entire path of the file but without its extension.

running the below script gives error at the statement DIR = `dirname $FILE` --command not found.

Code:
#!/bin/bash
jar xvf *jar

for FILE in `find . -name "*.class"`
  do
    echo $FILE
    DIR = `dirname $FILE`
    echo $DIR
 done


Last edited by Franklin52; 01-17-2011 at 04:25 AM.. Reason: Please use code tags
Sponsored Links
    #2  
Old Unix and Linux 01-16-2011   -   Original Discussion by amicableperson
Scrutinizer's Unix or Linux Image
Scrutinizer Scrutinizer is online now Forum Staff  
Moderator
 
Join Date: Nov 2008
Last Activity: 12 December 2017, 5:08 AM EST
Location: Amsterdam
Posts: 11,646
Thanks: 518
Thanked 3,385 Times in 2,984 Posts
Try:

Code:
echo "${FILE%.*}"

Sponsored Links
    #3  
Old Unix and Linux 01-16-2011   -   Original Discussion by amicableperson
amicableperson's Unix or Linux Image
amicableperson amicableperson is offline
Registered User
 
Join Date: Jan 2011
Last Activity: 3 November 2012, 1:21 PM EDT
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
somehow after rewriting my original script its working now..
thanks a lot for ur help !!!!
    #4  
Old Unix and Linux 01-16-2011   -   Original Discussion by amicableperson
itkamaraj's Unix or Linux Image
itkamaraj itkamaraj is offline Forum Advisor  
Registered User
 
Join Date: Apr 2010
Last Activity: 5 November 2017, 9:59 PM EST
Posts: 3,148
Thanks: 45
Thanked 698 Times in 674 Posts
the problem is the space

Code:
DIR = `dirname $FILE`

should be

Code:
DIR=`dirname $FILE`

Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
cut filename extension Essbaumer Shell Programming and Scripting 4 07-29-2010 06:18 AM
script takes the whole filename instead of just extension wolverine999 UNIX for Dummies Questions & Answers 1 05-20-2009 03:49 PM
changing filename extension Hiso Shell Programming and Scripting 3 01-24-2009 09:02 AM
separating filename and extension lucaspewkas Shell Programming and Scripting 2 04-06-2007 08:07 AM
filename extension check - regular expression devs Shell Programming and Scripting 4 03-02-2007 03:01 PM



All times are GMT -4. The time now is 06:10 AM.