Re: perl substitution question
Gary Kline wrote: Giorgos Keramidas wrote: Watch out for shells with funny 'expansion rules', like csh(1) :) [...] Man! truer words, (c)... . One o the very few suggestions left for improving shells [ and/or subshells ] is a flag, say '-N' which would have *nothing* to be escaped. In other words a '$' or '' would be interpreted literally. Everything between single quotes (') is taken literally and does not need to be escaped. Except for the single quote character itself, obviously, but that's not a big deal anyway. Best regards Oliver PS: I'm talking about standard bourne shell, of course (a.k.a. /bin/sh, zsh, ksh or bash). I recommend against using csh or tcsh. -- Oliver Fromme, secnetix GmbH Co. KG, Marktplatz 29, 85567 Grafing Dienstleistungen mit Schwerpunkt FreeBSD: http://www.secnetix.de/bsd Any opinions expressed in this message may be personal to the author and may not necessarily reflect the opinions of secnetix in any way. If you aim the gun at your foot and pull the trigger, it's UNIX's job to ensure reliable delivery of the bullet to where you aimed the gun (in this case, Mr. Foot). -- Terry Lambert, FreeBSD-hackers mailing list. ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: perl substitution question
On Jan 14, 2007, at 1:44 PM, Gary Kline wrote: Man! truer words, (c)... . One o the very few suggestions left for improving shells [ and/or subshells ] is a flag, say '-N' which would have *nothing* to be escaped. In other words a '$' or '' would be interpreted literally.But I'm sure there are reasons for not escaping some bytes. ZSH has the noglob keyword which can be quite useful... -- -Chuck ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: perl substitution question
On 2007-01-15 10:21, Chuck Swiger [EMAIL PROTECTED] wrote: On Jan 14, 2007, at 1:44 PM, Gary Kline wrote: Man! truer words, (c)... . One o the very few suggestions left for improving shells [ and/or subshells ] is a flag, say '-N' which would have *nothing* to be escaped. In other words a '$' or '' would be interpreted literally.But I'm sure there are reasons for not escaping some bytes. ZSH has the noglob keyword which can be quite useful... OMG! I managed to break a new shell war :) /me ducks and runs very far away ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: perl substitution question
On Tue, Jan 16, 2007 at 12:04:23AM +0200, Giorgos Keramidas wrote: On 2007-01-15 10:21, Chuck Swiger [EMAIL PROTECTED] wrote: On Jan 14, 2007, at 1:44 PM, Gary Kline wrote: Man! truer words, (c)... . One o the very few suggestions left for improving shells [ and/or subshells ] is a flag, say '-N' which would have *nothing* to be escaped. In other words a '$' or '' would be interpreted literally.But I'm sure there are reasons for not escaping some bytes. ZSH has the noglob keyword which can be quite useful... OMG! I managed to break a new shell war :) /me ducks and runs very far away No! no, cometh backeth, Giorgos! No war, just peace, love anf flowers:-) Actually, I do use zsh, just have no clue how to set noglob. I was going to ask, but didn't want to show my ignorance. [[ been using zsh for 16, 17 years... ]] Anyway, NOT to get into any kind of war--there being enuf stupidity in the world--but I'm thinking of having essentially a bare-threaded program loader. A trivial shell (tsh?) that does little more than take any ISO.8859-[1-2] character and do a fork-exec. Even [ which is really /usr/bin/test, would be sucked in as a plain [. I do a lot of regex stuff that meaning finding obscure patterns in text files or marked-up files. I've got the regex book and a cheatsheet several K lines long. () Chuck, exactly what does noglob do? How to set/unset, please? gary -- Gary Kline [EMAIL PROTECTED] www.thought.org Public Service Unix ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: perl substitution question
On Jan 15, 2007, at 2:29 PM, Gary Kline wrote: OMG! I managed to break a new shell war :) /me ducks and runs very far away No! no, cometh backeth, Giorgos! No war, just peace, love and flowers:-) % cd /usr/ports/mail/imap-uw/ make extract cd work/imap-2004g % tail -3 Makefile # A monument to a hack of long ago and far away... love: @echo not war? Actually, I do use zsh, just have no clue how to set noglob. I was going to ask, but didn't want to show my ignorance. [[ been using zsh for 16, 17 years... ]] [ ... ] Chuck, exactly what does noglob do? How to set/unset, please? noglob is a keyword (a precommand modifier, specifically) that disables wildcard filename globbing: % cd /tmp % touch 'a*' % touch 'ab' % ls a* a* ab % noglob ls a* a* This trivial case isn't too useful, but consider wanting to copy all .jpg files from your home directory on another machine to the local machine via scp or rsync: noglob scp [EMAIL PROTECTED]:*.jpg . It's also amazingly handy in conjunction with the find command: noglob find /usr/obj -name *.a ...so much so that I do: alias find='noglob find' ...in my ZSH environment. -- -Chuck ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: perl substitution question
On Mon, Jan 15, 2007 at 02:45:57PM -0800, Chuck Swiger wrote: On Jan 15, 2007, at 2:29 PM, Gary Kline wrote: OMG! I managed to break a new shell war :) /me ducks and runs very far away No! no, cometh backeth, Giorgos! No war, just peace, love and flowers:-) % cd /usr/ports/mail/imap-uw/ make extract cd work/imap-2004g % tail -3 Makefile # A monument to a hack of long ago and far away... love: @echo not war? This was from *mumble* years ago, but if you do a make love in most Makefiles, you'll get make: don't know how to make love. Stop; now is that old or what? Oh-well. Actually, I do use zsh, just have no clue how to set noglob. I was going to ask, but didn't want to show my ignorance. [[ been using zsh for 16, 17 years... ]] [ ... ] Chuck, exactly what does noglob do? How to set/unset, please? noglob is a keyword (a precommand modifier, specifically) that disables wildcard filename globbing: % cd /tmp % touch 'a*' % touch 'ab' % ls a* a* ab % noglob ls a* a* This trivial case isn't too useful, but consider wanting to copy all .jpg files from your home directory on another machine to the local machine via scp or rsync: noglob scp [EMAIL PROTECTED]:*.jpg . It's also amazingly handy in conjunction with the find command: noglob find /usr/obj -name *.a ...so much so that I do: alias find='noglob find' ...in my ZSH environment. Yes, indeed, thank you. After playing around for some minutes, your alias (or 'noglob find') finds much more easily. Live and learnobviously. gary -- -Chuck ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED] -- Gary Kline [EMAIL PROTECTED] www.thought.org Public Service Unix ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: perl substitution question
Thanks for all the ways, gents. (I never thought of tr, but now that seems like an option.) A week+ ago I tried perl using 's/\xNN//g' from the cmdline, but nojoy. The online docs said that \N{xx} would catch a hex character; that's what was fuzzy. {Very} early this morning I retried using \x80 and \x9d, \x9c separately. diff showed that things worked... mostly; then I found more hex characters that I had to carefully subs out. I'll write a script to do the whole bunch. No wonder I love Unix! gary -- Gary Kline [EMAIL PROTECTED] www.thought.org Public Service Unix ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: perl substitution question
On 2007-01-14 12:15, Gary Kline [EMAIL PROTECTED] wrote: Thanks for all the ways, gents. (I never thought of tr, but now that seems like an option.) A week+ ago I tried perl using 's/\xNN//g' from the cmdline, but nojoy. The online docs said that \N{xx} would catch a hex character; that's what was fuzzy. Watch out for shells with funny 'expansion rules', like csh(1) :) Even in sh(1) variants, it's always a good idea to save the Perl script in a file first, and test it independently of the shell, with: perl filter.pl infile outfile To avoid all the messy details about single-quotes, double-quotes, backquotes, stars, dollars, etc :) ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: perl substitution question
On Sun, Jan 14, 2007 at 10:31:04PM +0200, Giorgos Keramidas wrote: On 2007-01-14 12:15, Gary Kline [EMAIL PROTECTED] wrote: Thanks for all the ways, gents. (I never thought of tr, but now that seems like an option.) A week+ ago I tried perl using 's/\xNN//g' from the cmdline, but nojoy. The online docs said that \N{xx} would catch a hex character; that's what was fuzzy. Watch out for shells with funny 'expansion rules', like csh(1) :) Even in sh(1) variants, it's always a good idea to save the Perl script in a file first, and test it independently of the shell, with: perl filter.pl infile outfile To avoid all the messy details about single-quotes, double-quotes, backquotes, stars, dollars, etc :) Man! truer words, (c)... . One o the very few suggestions left for improving shells [ and/or subshells ] is a flag, say '-N' which would have *nothing* to be escaped. In other words a '$' or '' would be interpreted literally.But I'm sure there are reasons for not escaping some bytes. -- Gary Kline [EMAIL PROTECTED] www.thought.org Public Service Unix ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
perl substitution question
o Anybody know if I can do a perl substitution of the scads of \x80\x9D to simple double-quotes () from the command line? I've got many HTML files with this strange syntax (must be from Windows) that I'd like to make human-readable for myself. I know how to change s/OLD/NEW/ and make a *.bak of the old using perl from the cmd line. But nothing this obscure. ---Yes, I have scoured some web/perl docs; still fuzzy. thanks in advance, gary -- Gary Kline [EMAIL PROTECTED] www.thought.org Public Service Unix ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: perl substitution question
On 2007-01-13 18:45, Gary Kline [EMAIL PROTECTED] wrote: Anybody know if I can do a perl substitution of the scads of \x80\x9D to simple double-quotes () from the command line? You already have part of the syntax right: , | [EMAIL PROTECTED]:/home/keramida$ hd binary.dat | 80 68 65 6c 6c 6f 20 77 6f 72 6c 64 9d 0a|.hello world..| | 000e | [EMAIL PROTECTED]:/home/keramida$ perl -pe 's/\x80//; s/\x9d//;' binary.dat | hello world | [EMAIL PROTECTED]:/home/keramida$ ` Note how the file `binary.dat', which I edited with hexl-mode in Emacs, to insert the 0x80 and 0x9D hex values, gets converted to hello world on output. ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: perl substitution question
o Anybody know if I can do a perl substitution of the scads of \x80\x9D to simple double-quotes () from the command line? 80 hex = 200 octal 9D hex = 235 octal cat k | tr \200 \ | tr \235 \ k.new -- Matt Emmerton ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: perl substitution question
cat k | tr \200 \ | tr \235 \ k.new Or, skipping the unnecessary cat and invoking tr only once tr \200\235 \\ k k.new ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]