Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 12-27-2007, 04:32 PM   #1
LQ Newbie
Registered: Dec 2007
Posts: 4

Rep: Reputation: 0
assign converted string to variable

I am trying to assign a converted first name to the variable new but when I do an $echo $new, instead of the converted name being displayed, the whole line after the '=' sign is displayed, what am I missing?

new='echo "$fname" | tr [A-Z] [a-z]'

Old 12-27-2007, 04:54 PM   #2
harry edwards
Registered: Nov 2007
Location: Lincolnshire, UK
Distribution: CentOS, Fedora, and Suse
Posts: 365

Rep: Reputation: 48
I believe you meant to use the backward quote (`) instead if the single quote ('). This will force the script to execute the echo command and return the result into the variable.
Old 12-28-2007, 09:41 AM   #3
LQ Newbie
Registered: Dec 2007
Posts: 4

Original Poster
Rep: Reputation: 0

It worked like a charm! Am new to scripting and have never used the backward quote before! Thanks, you are the man!


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
How to assign a string to a structure variable in C? daYz Programming 10 07-06-2022 12:07 PM
bash script: how to assign an output (not the result) to a variable? Singing Banzo Programming 8 10-01-2006 07:29 PM
Shell script --cannot assign variable-- ralvez Programming 6 02-24-2006 05:56 PM
variable to string x2000koh Programming 4 07-30-2003 03:23 AM
Getting a variable name based on a string. jtshaw Programming 7 10-08-2002 03:06 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:01 PM.

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