The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Assigning output of command to a variable in shell sankar reddy Shell Programming and Scripting 6 02-28-2008 03:01 AM
assigning nawk output to shell variable user_prady Shell Programming and Scripting 6 11-29-2007 04:01 AM
assigning command output to a shell variable kprattip Shell Programming and Scripting 2 07-09-2007 05:01 AM
Assigning Value of variable janemary.a Shell Programming and Scripting 2 05-11-2007 06:53 AM
Assigning output of command to a variable oma04 Shell Programming and Scripting 5 06-27-2006 01:11 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-27-2008
jpmena jpmena is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 2
Assigning output to a variable

I am new to unix shell scripting.
I was trying to convert each lines in a file to upper case.
I know how to convert the whole file.
But here i have to do line by line.

I am getting it in the below mentioned script

#!/bin/bash
#converting lower to upper in a file

#tr "[:lower:]" "[:upper:]" <file1
FILE="jptest"
while read myline
do
orig=$myline
# new=`echo $myline | tr [a-t] [A-T]`
echo "$myline" |tr '[a-z]' '[A-Z]'
echo "Moving $orig --> $new"
done <jptest

This is giving me the correct answer.
But i want to take the output in a variable 'new'
I dont know how to do that..
Can you pl. help me out in this.
  #2 (permalink)  
Old 03-27-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
Look up backticks in your courseware hand-out.

Code:
variable=`some command whose output you want to capture`
You already have that, but it's commented out.
  #3 (permalink)  
Old 03-27-2008
jpmena jpmena is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 2
Quote:
Originally Posted by era View Post
Look up backticks in your courseware hand-out.

Code:
variable=`some command whose output you want to capture`
You already have that, but it's commented out.
Thats not working. is there nay syntax errors in that.
I am not getting the answer in $new
  #4 (permalink)  
Old 03-27-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
Yes, but you have the correct syntax elsewhere, so copy/paste whatever works to inside the backticks and you should be all set.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:00 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0