jpmena
March 27, 2008, 4:25am
1
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.
era
March 27, 2008, 4:31am
2
Look up backticks in your courseware hand-out.
variable=`some command whose output you want to capture`
You already have that, but it's commented out.
jpmena
March 27, 2008, 4:37am
3
era:
Look up backticks in your courseware hand-out.
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
era
March 27, 2008, 4:39am
4
Yes, but you have the correct syntax elsewhere, so copy/paste whatever works to inside the backticks and you should be all set.