LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-11-2004, 12:19 PM   #1
pauljtester
LQ Newbie
 
Registered: Apr 2004
Posts: 28

Rep: Reputation: 15
sed back referencing


Hi -

Is there a way to back reference things in sed similar to the perl ( ) reference? I'm changing the tiff2pdf bash script. The default output filename is foo.pdf. I'd like it to take the file name of whatever is being fed to the script, remove the tif portion and add .pdf.

For example:

$ tiff2pdf fax0000000001.tif

should output fax0000000001.pdf

Here's what I was thinking it was...but this isn't working

#out=foo.pdf # default output filename
out=`sed 's/(fax[0-9][0-9]*)\.tif/\1\.pdf/'`

Thanks for your help.
pjt
 
Old 11-11-2004, 12:47 PM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 68
Why not just use:
echo fax0000000001.tif | sed 's/tif$/pdf/'
 
Old 11-11-2004, 04:20 PM   #3
pauljtester
LQ Newbie
 
Registered: Apr 2004
Posts: 28

Original Poster
Rep: Reputation: 15
Good quesiton. I suppose I will just use that. It did exactly as I needed; I just changed

echo fax0000000001.tif
to
echo $1

and I'm set. Thanks for the help. pjt
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
BASH Script: variable values referencing for console arguments sadarax Programming 1 11-14-2005 05:23 PM
referencing a file - newbie question FastOwl MEPIS 4 07-05-2005 03:35 PM
When referencing a command, how far in depth can the symbolic link be followed? davidas Debian 2 04-12-2004 06:09 AM
PHP: referencing form elements with dynamic names Locura Programming 5 03-18-2004 10:24 AM
Insert character into a line with sed? & variables in sed? jago25_98 Programming 5 03-11-2004 06:12 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:32 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration