Getting filename with entire path without extension

Tags
shell scripts

Login to Reply

 
Thread Tools Search this Thread
# 1  
Old 01-16-2011
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
# 2  
Old 01-16-2011
Try:
Code:
echo "${FILE%.*}"

# 3  
Old 01-16-2011
somehow after rewriting my original script its working now..
thanks a lot for ur help !!!!
# 4  
Old 01-16-2011
the problem is the space
Code:
DIR = `dirname $FILE`

should be
Code:
DIR=`dirname $FILE`

Login to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Similar Threads More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to print full path name along with file extension? lijjumathew Linux 5 11-15-2017 12:57 PM
[BASH] Getting a filename its extension sea Shell Programming and Scripting 7 05-07-2015 05:58 AM
Remove the last 15 characters of a filename with respect to leave file extension ateya Shell Programming and Scripting 13 02-23-2014 11:46 PM
[Solved] Replace extension of filename stored in a variable rberkers Shell Programming and Scripting 2 02-07-2014 06:02 AM
Get latest filename without extension sumang24 Shell Programming and Scripting 7 12-11-2012 03:38 PM
BASH - Removing the very last character(s) extension of a filename jcdole UNIX for Dummies Questions & Answers 2 07-03-2012 02:43 PM
Rename all files (filename with spaces) to different extension mac4rfree Shell Programming and Scripting 1 06-13-2012 04:05 AM
move set of files to the target path with different extension kmanivan82 Shell Programming and Scripting 1 02-09-2012 04:14 PM
Script to add extension to filename repiv Shell Programming and Scripting 2 07-22-2011 06:30 PM
removing the filename extension daflore Shell Programming and Scripting 5 03-03-2011 05:43 PM
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 08:11 PM.

Unix & Linux Forums Content Copyright 1993-2018. All Rights Reserved.
UNIX.COM Login
Username:
Password:  
Show Password





Not a Forum Member?
Forgot Password?