On Friday 15 February 2008 08:51, David C. Rankin wrote:
Listmates,
Every time I run into sed, it's a fight. I'm trying to locate a " and then strip the quote and everything that follows from each line in a file called "myfile". I am obviously horribly confused with the ranges escaped parentheses and \1 remembered patterns. Surely sed can do this, but the trees are obscuring the forest. The lines I have in myfile are all like:
/home/icons-2/filename.gif">capital seal 1</A>
The problem I am having is that the " is in the middle of a 'word' so something like cat ~/tmp/myfile | sed 's/"\([0-9A-Za-z]*\)*/\1/' doesn't work. Something as simple as cat ~/tmp/myfile | sed 's/"//' does find the " and delete it, but how do I get rid of the rest of the line?
Sed is an odd duck, though mostly only in its more esoteric options and operations. This one's pretty simple: sed -e 's/".*//' ~/tmp/myfile >resultFile Please break yourself of the habit of doing "cat someFile |someCommand" Very, very few Unix command do not take file names as specifications of the input on which to operate.
Help!
Calm down.
-- David C. Rankin
Randall Schulz -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org