LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 01-12-2009, 08:08 AM   #1
alekone
LQ Newbie
 
Registered: Dec 2008
Posts: 7

Rep: Reputation: 0
shell script: how to insert a command into quotes


hello!
I'm running this command
Code:
convert -format jpg "$i" "/Volumes/TESTHD/JPEG/$i.jpg"
(it's an imagemagick command)

the problem is, it produces files with double extension (.tif.jpg).
to avoid this, I'd like to use something like basename $i, but I don't know hot to put it inside the quotes.

i tried

Code:
convert -format jpg "$i" "/Volumes/TESTHD/JPEG/basename $i.jpg"
but obviously it doesn't work. help!
 
Old 01-12-2009, 08:12 AM   #2
eco
Member
 
Registered: May 2006
Location: BE
Distribution: Debian/Gentoo
Posts: 412

Rep: Reputation: 48
Try something like this:

Code:
convert -format jpg "$i" "/Volumes/TESTHD/JPEG/`echo ${i}|cut -d. -f1`.jpg"
Hope this helps.

Last edited by eco; 01-12-2009 at 08:14 AM.
 
Old 01-12-2009, 08:19 AM   #3
alekone
LQ Newbie
 
Registered: Dec 2008
Posts: 7

Original Poster
Rep: Reputation: 0
thank you! super-fast answer
I'll give it a try.

I (almost) understand what it does, but why do you need {}?
 
Old 01-12-2009, 08:46 AM   #4
eco
Member
 
Registered: May 2006
Location: BE
Distribution: Debian/Gentoo
Posts: 412

Rep: Reputation: 48
Hi,

Not so fast answer

The '{}' is only to make sure the variable is clearly defined. Just something I tend to always do.

It avoids problems like

Code:
#!/bin/bash
i="foo"
echo "$ibar"    # $ibar does not exist
echo "${i}bar"
 
Old 01-12-2009, 08:56 AM   #5
alekone
LQ Newbie
 
Registered: Dec 2008
Posts: 7

Original Poster
Rep: Reputation: 0
got it!
I meant: thank you for your answer, you answered in a really short time in my opinion.
sorry for my poor english.
thank you, again!
 
  


Reply

Tags
bash, shell script


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell Script to insert value in database deepu_linux Programming 14 04-25-2013 12:07 PM
Shell Script format question - output command results in quotes Barefootpanda Linux - General 5 10-13-2008 11:40 PM
Shell Script: want to insert values in database when update script runs ring Programming 2 10-25-2007 10:48 PM
same find command not working in bash script, quotes? QuakerOatz Linux - Software 1 07-14-2003 12:04 PM
passing quotes in shell script Tenor Trombone Programming 1 04-18-2001 09:26 PM


All times are GMT -5. The time now is 11:06 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration