i am writing a shell , which will get input from the user and then try to change the CASE to lower
echo "Please enter the unix server name ::"
read unix1
unix 2 =tr '[A-Z]' '[a-z]' < $unix1
echo $unix2
its not giving me the result in lower case..
User input will be in Upper case and this has to convert to lower case and then only i can find the path of the server name which should be in lower case
You have a number of errors in there. Perhaps simply posting a correct solution is a bit of a cheat, but you need to understand at least that redirection operates on file names, not strings (so < $unix1 doesn't do what you want) and you need to use $(...) or `...` to actually execute the tr command. var=value foo bar means "assign value to $var, then execute foo bar while this assignment is in place."
or if you need the value to be in $unix2,
If your shell is very old, you will need to use backticks (grave accents, ASCII 96 -- not regular single quotes) instead of $(...).
Last edited by era; 09-25-2008 at 03:45 AM..
Reason: How to properly capture result in unix2
Hi,
I have the files in the following files in a folder
19996587342
19487656550
19534838736
And i need to get the first 6 characters from the abvoe files
so i used the following script
#!/bin/ksh
for i in 19*
do
txt= `$i | cut -c -6`
echo "$txt"
done
The error is at... (4 Replies)
Hi All,
I have a file which has hundred of records with fixed number of fields. In each record there is set of 8 characters which represent the duration of that activity. I want to sum up the duration present in all the records for a report. The problem is the duration changes per record so I... (5 Replies)
Hi all,
Hereby wish to have your advise for below:
Main concept is
I intend to get current directory of my script file.
This script file will be copied to /etc/init.d.
A string in this copy will be replaced with current directory value.
Below is original script file:
... (6 Replies)
Getting the below error while executing this. Able to run the below commands Individually.
#!/bin/bash
a=$(printf "%d\n" 0x01E);
b=$(printf "%d\n" 0x01A);
echo $a
echo $b
c=`expr $a - $b`
echo $c
syntax error at line 2: `a=$' unexpected (2 Replies)
can anyone please help me with this:
i have written a shell script and a stored procedure which has one OUT parameter. now i want to use that out parameter as an input to the unix script but i am getting an error as variable not found. below are the unix scripts and stored procedure...
... (4 Replies)
Hi,
I am trying to do the following thing
var='date'
$var
Above command substitutes date for and in turn runs the date command and i am getting the todays date value.
I am trying to do the same thing as following, but facing some problems,
unique_host_pro="sed -e ' /#/d'... (3 Replies)
Dear all,
I have basic knowledge of Unix script and her I am trying to process variable length and variable format CSV file.
The file length will depend on the numbers of Earnings/Deductions/Direct Deposits.
And
The format will depend on whether it is Earnings/Deductions or Direct Deposits... (2 Replies)
Hi all,
I have a variable say var1 (output from somewhere, which I can't change)which store something like this:
echo $var1
name=fred
age=25
address="123 abc"
password=pass1234
how can I make the variable $name, $age, $address and $password contain the info?
I mean do this in a... (1 Reply)
I want to instert Category:XXXXX into the 2. line
something like this should work, but I have somewhere the wrong sytanx. something with the linebreak goes wrong:
sed "2i\\${n}Category:$cat\n"
Sample:
Titel Blahh Blahh abllk sdhsd sjdhf
Blahh Blah Blahh
Blahh
Should look like... (2 Replies)
Hello,
i have another sed question.. I'm trying to do variable substition with sed and i'm running into a problem.
my var1 is a string constructed like this:
filename1 filerev1 filepath1
my var2 is another string constructed like this:
filename2 filerev2 filepath2
when i do... (2 Replies)