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




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 05-13-2009
Mr.Lauren Mr.Lauren is offline
Registered User
  
 

Join Date: Apr 2009
Posts: 3
sed -i '7 c\$variable' file ....(?!@#$%^&*!)

I have tried everything I can think of to get sed to change line N of a file to the contents of a variable. I have Googled the Internet, and I find lots of people telling how to use variables with the "Substitute" command, but no one telling how to use variables with the "Change" command.

I have considered the possibility of using the "Substitute" command with a wild card for existing text, but my search of the Internet tells me SED doesn't have wild cards in its repertoire, so it's difficult! There must be a better way.

As I noted in the subject, the basic form I used is (where N is a line number):
Code:
sed -i 'N c\$variable' FILE
Is this possible, or is there a different command that will do it? I am working in BASH scripts.

Thanks!