Spiro Harvey wrote:
Can anyone recommend a program/shell script/editor plugin etc, that
can take arbitrary text as input and quote it like email programs
quote emails with a preceding "> " character?
awk '{print "> " $0}' filename
or just type:
awk '{print "> " $0}'
paste some text into the buffer, and hit ctrl-D when you're done. It'll
return the quoted text which you can paste into your webpage.
I've been learning to use sed and awk and grep, etc., lately.
I have a general question (probably more appropriate elsewhere, but I'm
going to ask here anyway. Smack me later.).
Why is it that with sed, stuff like
sed -e /searchterm/d
I have to do
sed -e /searchterm/d infile > outfile,
and can't just do sed -e /searchterm/d file, without having to generate
another file?
If I just do sed -e /searchterm/d file
I get output to the terminal, but no change to file.
Likewise, I have to the same with grep
like
grep -v "^$" filename > newfilename
I can't just to grep -v "^$" filename
and have grep do its magic on filename, without generating a second
output file.
(I used both of these today to manipulate a script to remove duplicate
files on my system, which I found at
http://elonen.iki.fi/code/misc-notes/remove-duplicate-files/ this
generated a script that listed all duplicate files with rm at each line,
then used sed to remove certain lines from that script, to preserve
certain files, used grep to remove the empty lines...just to look nicer).
It seems fmt does the same, and, I believe awk, as well.
As such, while manipulating my script today, I kept having to do stuff like
sed -e "/.gconf/d" script > script2
mv script2 script
rm script2
sed -e "/.java/d" script > script2
mv script2 script
rm script2
I was trying to use sed to manipulate the script rather than just open
it in a text editor and edit it by hand, but, in the long run, it didn't
come out much more efficient...
I suppose had I done
sed -e "/.gconf/d" script > script0
sed -e "/.java/d" script0 > script1
sed -e "/.adobe/d" script1 > script2
sed -e "/docs\/.evilplans\/todo/d" script2 > script3
(etc.)
sed -e "/finalsearchterm/d" script25 > MyFinalScript
rm script*
maybe I could have further automated this, but, it just seems that if
sed would work on a target file, without have to be ">"ed to an output
file, that it would be more efficient. I mean, in the above case, I end
up with 25 scripts before I'm done manipulating the text.
I feel like I must be missing something really essential here, because I
imagine this could be done more efficiently.
Sorry if this is the wrong place to ask, but I'm just really an infant
with bash scripting, eager to learn, and following some of these threads
has been enlightening.
be well,
tony
--
http://www.photodharma.com
art / photos / music / tony baldwin
--
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org