0

If I have something like this:

file=abcdefg.url
echo $file

is there a way I can make it so that when I export using > I can export it to an html file by substituting the .url with a null character and appending .html?

for example:

x=(sed -n 's/URL=//p' $f) 
$out=$file.html
//replace .url with a null here
$x>$out

Thanks in advance!

iruvar
  • 22,736
  • 7
  • 53
  • 82
Skorpius
  • 2,135
  • 2
  • 26
  • 31
  • 1
    possible duplicate of [Bash script: remove extension from file name](http://stackoverflow.com/questions/14703318/bash-script-remove-extension-from-file-name) – tripleee Jun 08 '14 at 17:00

2 Answers2

-1

Something like this...

out=`echo file.url | sed 's/\..*//'`.html
$x>$out

or (as I am learning) a better way is:

out=$(echo file.url | see 's\..*//').html
Jotne
  • 40,548
  • 12
  • 51
  • 55
John C
  • 4,276
  • 2
  • 17
  • 28
-1

You want to rename the file whose name is in $file from something.url to something.html, right?

If so, and assuming your shell is bash, you may want to use bash suffix removal in this way:

x=(sed -n 's/URL=//p' $f) 
$out=${file%\.url}.html
$x>$out

It should remove the .url suffix from the string contained by $file.

man bash for more details about it.

Qeole
  • 8,284
  • 1
  • 24
  • 52