[Urgent] Unix Help required

raksrules

Elite
In Unix i am using the following command to read one line from a file and echo it but this does not work. I have used it before (in another project) and it had worked there

Code:
cat /usr/tmp/abc.txt | read errcode
echo $errcode

Is there any other way i can read from this file which will have only one line.
 
then may be this work out for you

Code:
errcode=`cat /usr/tmp/abc.txt`

echo $errcode

Code:
[kekerode@m-net ~]$ cat abc.txt

skjdajkdakjdasjkdas

[kekerode@m-net ~]$ echo $err123

[kekerode@m-net ~]$ err123=`cat abc.txt`

[kekerode@m-net ~]$ echo $err123

skjdajkdakjdasjkdas

[kekerode@m-net ~]$
 
kekerode said:
then may be this work out for you

Code:
errcode=`cat /usr/tmp/abc.txt`
echo $errcode

Code:
[kekerode@m-net ~]$ cat abc.txt
skjdajkdakjdasjkdas
[kekerode@m-net ~]$ echo $err123

[kekerode@m-net ~]$ err123=`cat abc.txt`
[kekerode@m-net ~]$ echo $err123
skjdajkdakjdasjkdas
[kekerode@m-net ~]$

Yeah this one worked perfect. :hap2:

nukeu666 said:
try this...should work for file of any length

cat my.file | while read LINE ; do
<work>
done

I had tried this but it did not work.
 
Back
Top