Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sed & variable

Status
Not open for further replies.

Komil13

Programmer
Sep 26, 2001
50
US
Hi,

How do I use a variable with sed?? For example:

if i set a $USER to be kjones

then insert the $USER variable in the first line of a file, using the below command

sed -e '1i$USER' | cat > temp

but this doesn't work ... i get $USER in the file and not the value.
 
apart from the useless use of cat award ...

sed -e "1i\$USER" > temp

works.
 
Thanks Jad ... that worked just perfectly ...
 
if you really will use cat (in your example):

(
echo $user
cat filename
) >temp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top