Results 1 to 2 of 2
Given the following code I am expecting the variable NewFile to be: myfile.txt.pdf
However my system is returning the following: ".pdfest.txt" without quotes.
Code:
FileName=`head $f -n1 | awk -F/ ...
- 11-06-2009 #1Just Joined!
- Join Date
- Nov 2009
- Posts
- 3
Bash script variable substitution help
Given the following code I am expecting the variable NewFile to be: myfile.txt.pdf
However my system is returning the following: ".pdfest.txt" without quotes.
Any help is appreciated, please note that I am newb and know little to nothing about linux.Code:FileName=`head $f -n1 | awk -F/ '{print $NF}' | sed 's/\"//'` #this returns "myfile.txt" no quotes Ext="${FileName##*.}" xPdf=".pdf" fn="${FileName}" NewFile="${fn}${xPdf}"
- 11-07-2009 #2
that's strange...
i tried:
it does what is expected.Code:#!/bin/bash # FileName=`head $f -n1 | awk -F/ '{print $NF}' | sed 's/\"//'` #this returns "myfile.txt" no quotes FileName=myfile.txt Ext="${FileName##*.}" # no effect on outcome xPdf=".pdf" fn="${FileName}" NewFile="${fn}${xPdf}" echo $NewFile # outputs: myfile.txt.pdf
are you sure you're using bash...?


Reply With Quote
