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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sed question

Status
Not open for further replies.

dtanner

Technical User
Dec 19, 2001
10
US
Hi all,
I am attempting to remove a random line in a file. I am thinking that sed should do it something like this:
cat access | sed '/$choice/d' > access.new
Where $choice is a variable filled in by the user, but alas, it does not work.
Thanx in advance!
DT In order to prevent possible injury to yourself, or your computer, and to ensure readability, please do not smoke, eat, drink, spindle, bend, fold, staple, or mutilate this message.
 
Never mind. I just needed double quotes instead of single quotes.
In order to prevent possible injury to yourself, or your computer, and to ensure readability, please do not smoke, eat, drink, spindle, bend, fold, staple, or mutilate this message.
 
Thanks for 'not working'? ;)

Problems:
1. shell quoting
2. UUOC

sed "/${choice}/d" access > access.new vlad
+---------------------------+
|#include<disclaimer.h> |
+---------------------------+
 
Thanx!! I will change it again.
DT In order to prevent possible injury to yourself, or your computer, and to ensure readability, please do not smoke, eat, drink, spindle, bend, fold, staple, or mutilate this message.
 

why you cat filename|sed ??
this is correct and really NOT the same: cat filename*|sed
else sed '.....' filename >newfname
vox clamantis in deserto.
 
#define UUOC &quot;UselessUseOfCat&quot; vlad
+---------------------------+
|#include<disclaimer.h> |
+---------------------------+
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top