Create a folder from a file name
I have a files called STMam.bam.
Now i want to create a directory with the same name as the file but it should exclude the .bam extension. The folder created should be named as STMam. |
erm... "mkdir STMam" will do that... if you're after help with scripting or programming, you need to provde more useful information here. the basename tool will probably help you a lot.
|
Sg like this
Code:
FILENAME=stmam.bam; DIRNAME="${FILENAME%\.*}"; echo $DIRNAME |
While I like the solution I am curious why the escape? A period is not special when globbing nor to the shell so the escape, as far as I can tell, serves no benefit.
|
Quote:
DIRNAME=$(echo ${FNAME/.*/}) echo $DIRNAME will show you directory name mkdir "${FN%.*}" DIR_NAME=$(echo ${FILENAME} | awk -F. '{ print $4 }') mkdir ${DIR_NAME} |
I am not sure what you are trying to show here? Well apart from the fact that you are using your own solution and not the example by NevemTeve
|
Sure, I checked the manual again, dot doesn't have special meaning in this context, so it is unnecessary to escape it. My fault.
|
All times are GMT -5. The time now is 07:18 AM. |