The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Replacing a string in nth line maxmave Shell Programming and Scripting 1 06-04-2008 02:32 PM
To cut end string from line visu Shell Programming and Scripting 7 12-20-2007 11:22 PM
regexp to get first line of string jonas.gabriel Shell Programming and Scripting 3 05-09-2007 12:46 AM
get the NF of a string line ozzman Shell Programming and Scripting 5 02-01-2007 10:01 PM
How I Can get String From the Line habuzahra UNIX for Dummies Questions & Answers 2 10-29-2006 04:55 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 10-13-2005
Registered User
 

Join Date: Mar 2005
Posts: 15
Unhappy Add string after line X

Hi all,

I'm trying in a script, to add a string after the line number one.

file=file.txt
text="it works"

sed '1i\ $text' < $file

But I'm getting the following err:
"Function 1i\ $text cannot be parsed."

Does anyone knows the reason why this err is happening or knows another way to do it ?

Thanks!
Reply With Quote
Forum Sponsor
  #2  
Old 10-13-2005
blowtorch's Avatar
Supporter
 
Join Date: Dec 2004
Location: Singapore
Posts: 2,328
Dont use single quotes ('). Use double quotes ("). This will allow the shell to substitute the value of the variable $text in its place.
Reply With Quote
  #3  
Old 10-13-2005
zazzybob's Avatar
Registered Geek
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
Check out our FAQ area as this has been covered before.

Cheers
ZB
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 06:14 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0