The UNIX and Linux Forums  

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




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #7 (permalink)  
Old 07-18-2008
gugs gugs is offline
Registered User
  
 

Join Date: Jul 2008
Posts: 44
The code below works:

Range1="${keys[$i]}"
Range2="${keys[$i+1]}"
a="sed -n /"
b="/,/"
c="/p"
echo "$a$Range1$b$Range2$c" > temp1.txt
sedcmd=$(grep sed temp1.txt)
errordata=$($sedcmd < test1.txt)
echo "$errordata" > temp2.txt

However, I am having to echo the contents of the variable to a file which I process further.

What I would like to do is send the data from the $sedcmd < test1.txt to temp2.txt by using: cat test1.txt | $($sedcmd) > temp2.txt. However, this gives me 'No such file or directory' errorr