Go Back   The macosxhints Forums > OS X Help Requests > UNIX - General



Reply
 
Thread Tools Rating: Thread Rating: 8 votes, 5.00 average. Display Modes
Old 11-21-2002, 09:57 AM   #1
steve_rothman
Prospect
 
Join Date: Oct 2002
Posts: 13
does "sed" work differently on Darwin/tcsh?

I'm working with a nice list of sed one-liners, from:

http://sed.sourceforge.net/grabbag/t.../oneliners.txt

Some seem to work great on my 10.2 system, but some don't. The one I'm especially interested in is a one-liner to strip html from text files:

# remove most HTML tags (accommodates multiple-line tags)
sed -e :a -e 's/<[^<]*>/ /g;/</{N;s/\n/ /;ba;}'

This gives me an error msg:

sed: 1: "s/<[^<]*>/ /g;/</{N;s/\ ...": unexpected EOF (pending }'s)

I don't know enough about sed to debug this, I assume the one-liner is basically correct and this may be an issue with tcsh?

Any hints?
steve_rothman is offline   Reply With Quote
Old 11-21-2002, 10:16 AM   #2
osxpez
Major Leaguer
 
Join Date: May 2002
Location: Sweden
Posts: 282
It's not tcsh. But GNU sed is very much like vanilla sed on steroids and it might be that OSX doesn't come with GNU sed. Try installing sed with fink and you shall find that that one liner will work.
__________________
/PEZ
osxpez is offline   Reply With Quote
Old 11-21-2002, 10:32 AM   #3
steve_rothman
Prospect
 
Join Date: Oct 2002
Posts: 13
Thanks for the tip. If anyone already has GNU sed installed, can you try this?

I believe it is intended to work with the plain vanilla sed, and I try to avoid stuff with steroids when they're not necessary.

I noticed warnings in the sed documentation that some examples don't work properly in bash or tcsh shells. The problems I saw mentioned (like using a "!") don't seem to affect this example but I think it's quite possible that the shell is "interpreting" some portion of the one-liner and not sending the right parameters to sed?
steve_rothman is offline   Reply With Quote
Old 11-21-2002, 10:34 AM   #4
sao
Moderator
 
Join Date: Jan 2002
Location: Singapore
Posts: 4,237
steve_rothman,

Or install, also with Fink:

ssed-3.58-1
Description:------Super stream editor

based on GNU sed 3.02.80 several new features (including in-place editing of files, extended regular expression syntax and a few new commands).

Check it up here:

http://sed.sourceforge.net/grabbag/ssed/


Cheers...
sao is offline   Reply With Quote
Old 11-21-2002, 11:20 AM   #5
osxpez
Major Leaguer
 
Join Date: May 2002
Location: Sweden
Posts: 282
Quote:
Originally posted by steve_rothman
Thanks for the tip. If anyone already has GNU sed installed, can you try this?

I tried it on a GNU/Linux box with both bash and tcsh. It works. (Even if it outputs a lot of empty lines, so it can be improved.)
Quote:
Originally posted by steve_rothman
I believe it is intended to work with the plain vanilla sed, and I try to avoid stuff with steroids when they're not necessary.

But GNU sed is the defacto standard so you probably should be using it.
Quote:
Originally posted by steve_rothman
I noticed warnings in the sed documentation that some examples don't work properly in bash or tcsh shells. The problems I saw mentioned (like using a "!") don't seem to affect this example but I think it's quite possible that the shell is "interpreting" some portion of the one-liner and not sending the right parameters to sed?

Well, in this case the sed script is fully enclosed in single quotes, and not even tcsh should be able to touch it!
__________________
/PEZ

Last edited by osxpez; 11-21-2002 at 02:29 PM.
osxpez is offline   Reply With Quote
Old 11-21-2002, 11:29 AM   #6
mervTormel
League Commissioner
 
Join Date: Jan 2002
Posts: 5,536
another (right) tool for the job...
Code:
$ cat ~/bin/dhtml

#!/usr/bin/perl -w

#strip html tags

while (<>) {
  $_ =~ s/<[^>]*>//g;
  print;
}

$ curl -s http://checkip.dyndns.org | dhtml
Current IP Check


Current IP Address: x.x.x.x
Hostname: foo.bar.blaz.com
[edit: concede to pez's claim -mt]
__________________
On a clear disk, you can seek forever.

Last edited by mervTormel; 11-21-2002 at 12:37 PM.
mervTormel is offline   Reply With Quote
Old 11-21-2002, 12:05 PM   #7
osxpez
Major Leaguer
 
Join Date: May 2002
Location: Sweden
Posts: 282
Well sed seems to be the right tool for the job as well. Using the one-liner above:

$ curl -s http://checkip.dyndns.org | sed -e :a -e 's/<[^<]*>/ /g;/</{N;s/\n/ /;ba;}'

Avoids bringing up a a bloaty Perl interpreter. Then you have awk:

$ curl -s http://checkip.dyndns.org | awk -v RS='<[^<]*>' '{print}'
__________________
/PEZ
osxpez is offline   Reply With Quote
Old 11-21-2002, 02:17 PM   #8
sao
Moderator
 
Join Date: Jan 2002
Location: Singapore
Posts: 4,237
steve_rothman,

I think you better follow osxpez good advice.

It also works well in tcsh:
Code:
1 [sao @/Users/sao] : curl -s http://checkip.dyndns.org | sed -e :a -e 's/<[^<]*>/ /g;/</{N;s/\n/ /;ba;}'
   Current IP Check  
 

 Current IP Address: x.x.x.x
 Hostname: bubu-00-00-00.papata.bata.lata

Cheers...

Last edited by sao; 11-21-2002 at 02:20 PM.
sao is offline   Reply With Quote
Old 11-21-2002, 02:48 PM   #9
osxpez
Major Leaguer
 
Join Date: May 2002
Location: Sweden
Posts: 282
gawk

I don't know why Apple choose to not use more GNU tools. But when I tried my own awk one-liner on my Mac i see that it doesn't work! I haven't checked what version of awk that comes with OS X, but it's neither mawk nor gawk, because then it would have worked. (Both treats RS as a regexp.) The fix was surprisingly simple:

$ sudo apt-get install gawk

'Surprisingly' because since Jaguar, few packages have been apt-get-able and I have gotten quite used to being forced to use fink. gawk seems to be in the exclusive set of tools that has a binary dist.
__________________
/PEZ
osxpez is offline   Reply With Quote
Old 11-21-2002, 03:17 PM   #10
sao
Moderator
 
Join Date: Jan 2002
Location: Singapore
Posts: 4,237
osxpez,

There are several packages you could install with apt-get now, although I don't recommend it in Jaguar, until they release Fink-0.5.0. which will be probably next week, and then, quite a few binary packages will be available to install with apt-get and dselect.

By the way, 'fink install gawk' takes from start to finish, exactly 3 minutes on an iMac 400 MHz.


Cheers...
sao is offline   Reply With Quote
Old 11-21-2002, 03:32 PM   #11
osxpez
Major Leaguer
 
Join Date: May 2002
Location: Sweden
Posts: 282
It took just a few seconds using apt-get. When you say several packages being available through apt-get. Do you mean the 15 or so packages (of which most of them are Fink stuff) listed by "dpkg -l" or can I reach other packages as well?

Fink 0.5.0 within a week! That's great news! Any idea of when we can have a kde 3 on Jaguar? One of the things I lack the most from 10.1 is Eterm. xterm sucks ass since it's slower than a pregnant cow swimming in maple syrup. Will I see Eterm in Fink 0.5.0 you think? Sorry for straying away with this thread. ...
__________________
/PEZ

Last edited by osxpez; 11-21-2002 at 03:42 PM.
osxpez is offline   Reply With Quote
Old 11-21-2002, 08:48 PM   #12
pmccann
Major Leaguer
 
Join Date: Jan 2002
Location: Adelaide, South Australia
Posts: 470
Sorry, but giggling seems highly appropriate at this stage!

Avoid bringing up a "bloaty" perl interpreter; instead use awk. No, not awk, but *sed*, you know, the new "default" sed. Not the sed that you might have. Or awk, but not *awk*, the *real* awk, which is gawk (or maybe you might need mawk, who knows? Hang on, maybe that's nawk? Now which version was it that changed the regular expression syntax to the way that I use it here?). Just download the appropriate version; takes hardly any time at all (compared to starting up that bloaty perl interpreter!).

Redux: if you're running a machine that's capable of "producing" Mac OS X then the time spent wondering whether to use a porcine perl or an antsy awk or a slender sed is a dozen times longer than it would take to run any of these utilities a dozen times.

If you want to wear a belt with a corkscrew, a knife, a gknife (the new standard -- of course!!) a hoof-cleaner (for wildebeest) and a pair of scissors attached then that's your business, and maybe that of the fashion police. Give me a swiss-army chainsaw any day. It'll be cranked into action in a fraction of the time that you spend sorting through your dinky dingly dangly dongles. Reminds me of a very silly little piece of video: "why sumo is better than karate"....

http://www.nivenspaws.com/whysumoisb...hankarate.mpeg

Cheers,
Paul (guess I should add in a debitchifying smiley at this stage? )

ps forgive me: it's been a really bad couple of days...
pmccann is offline   Reply With Quote
Old 11-21-2002, 09:02 PM   #13
mervTormel
League Commissioner
 
Join Date: Jan 2002
Posts: 5,536
ha! thanks, /usr/bin/paul -- i appreciate your perspective.

somewhere i saw 'snawk' -- new and improved awk! now with more sed!
__________________
On a clear disk, you can seek forever.
mervTormel is offline   Reply With Quote
Old 11-21-2002, 11:27 PM   #14
sao
Moderator
 
Join Date: Jan 2002
Location: Singapore
Posts: 4,237
osxpez,

Yes, still I would tell you that the only way to install in Jaguar at the moment is from source and to wait for Fink-0.5.0 to install binaries using apt-get.

About kde 3, in reality it already does work very well on Jaguar, you just have to install it from source. Same for Eterm. I really don't know which binary packages will be inmediately available with the new release.

As you know, the quantity of packages available in binary much depends on the feedback given to the maintainers, so if there is positive feedback about using a package in unstable, they can move it to the stable branch. For the last month or so, the Fink maintainers have being calling for feedback from users, preparing for the release of 0.5.0.


Cheers...
sao is offline   Reply With Quote
Old 11-22-2002, 01:08 AM   #15
osxpez
Major Leaguer
 
Join Date: May 2002
Location: Sweden
Posts: 282
paul: Sorry if I stepped on a soar Perl toe. I still think it's worthwhile to have the GNU versions of awk and sed. (And if you think it was about regexp syntax you should check again, the same expression was used through all seds/awks and even Perl.) By the way I've seen people using MS Word macros for tasks like stripping HTML. In that comparison Perl seems light weight. (And awk and sed more like spit in the ocean.)

sao: Eterm and KDE 3 are not available via fink (as far as I can see) so there's no way to test them in unstable. What do you mean by installing them from source? Grab the tar balls from the respective sites and have a go? I might do that with Eterm.
__________________
/PEZ
osxpez is offline   Reply With Quote
Old 11-22-2002, 02:41 AM   #16
thatch
All Star
 
Join Date: Jan 2002
Posts: 534
osxpez, I find eterm and KDE 3 stuff when I do a 'sudo fink list':

eterm 0.9-1 Color VT102 terminal emulator
----

kaboodle 3.0.7-3 KDE - simple media player
kalzium 3.0.7-3 KDE - periodic table
kaphorism 3.0.7-3 KDE - display proverbs and aphorisms
...
kxine 0.5-0.20020 KDE DVD and video player.
kxmlrpcd 3.0.7-3 KDE - inter-process communcation server

----

A 'sudo fink install eterm' should certainly work for a compile from source. KDE would take a long time but is also doable.

I don't know if those are in unstable or not for your testing. I think those listed are more likely stable versions but I could be wrong. I guess that running the 'sudo fink selfupdate-cvs' and then a 'fink update-all' afterwards would get you the latest available though.
thatch is offline   Reply With Quote
Old 11-22-2002, 04:43 AM   #17
sao
Moderator
 
Join Date: Jan 2002
Location: Singapore
Posts: 4,237
osxpez,

I missed your last post above, sorry. (just read it)

Like thatch said, if you run 'fink selfupdate-cvs' , and 'fink update-all', they will come up sooner or later in your 'sudo fink list'.

What's you fink version right now?? (fink -V)


Cheers...

Last edited by sao; 11-22-2002 at 02:37 PM.
sao is offline   Reply With Quote
Old 11-22-2002, 04:48 AM   #18
sao
Moderator
 
Join Date: Jan 2002
Location: Singapore
Posts: 4,237
thatch, osxpez,

Actually, in Jaguar (10.2) you can install right now from source, with 'fink install packagename' the following KDE 3 packages:
Code:
228 Sao  @ ~  $ fink list -i --section=kde
Information about 1759 packages read in 1 seconds.

 i   amor                   3.0.7-3          KDE - themeable animated window toy
 i   ark                    3.0.7-3          KDE - archive utility
 i   arts                   1.1.0-3          KDE - analog realtime synthesizer
 i   arts-dev               1.1.0-3          KDE - static libraries and headers for aRts
 i   atlantik               3.0.7-3          KDE - monopoly-like game
 i   flashkard              3.0.7-3          KDE - vocabulary studying tool
 i   kalzium                3.0.7-3          KDE - periodic table
 i   kaphorism              3.0.7-3          KDE - display proverbs and aphorisms
 i   karbon                 1.2.0-3          KDE - vector-based drawing program
 i   kasteroids             3.0.7-3          KDE - asteroids clone
 i   katomic                3.0.7-3          KDE - sokoban-like game
 i   kbackgammon            3.0.7-3          KDE - backgammon board game
 i   kbattleship            3.0.7-3          KDE - battleship clone
 i   kblackbox              3.0.7-3          KDE - blackbox clone
 i   kbounce                3.0.7-3          KDE - catch moving balls
 i   kcalc                  3.0.7-3          KDE - scientific calculator
 i   kcharselect            3.0.7-3          KDE - character set selector
 i   kchart                 1.2.0-3          KDE - charting and diagram drawing
 i   kcoloredit             3.0.7-3          KDE - color palette editor
 i   kde-extra-kfile-plugi  3.0.7-3          extra file I/O plugins
 i   kde-extra-screensaver  3.0.7-3          KDE - extra screensavers
 i   kde-extra-sounds       3.0.7-3          KDE - extra sounds for startup and logout
 i   kde-extra-themes       3.0.7-3          KDE - extra window styles and themes
 i   kde-extra-wallpapers   3.0.7-3          KDE - extra wallpaper images
 i   kde-icons-crystal      3.0.7-3          KDE - "Crystal" icon set
 i   kde-icons-ikons        3.0.7-3          KDE - "ikons" icon set
 i   kde-icons-locolor      3.0.7-3          KDE - "Locolor" icon set
 i   kde-icons-slick        3.0.7-3          KDE - "slick" icon set
 i   kde-icons-technical    3.0.7-3          KDE - "Technical" icon set
 i   kde-panel-eyes         3.0.7-3          KDE - xeyes panel applet
 i   kde-panel-fifteen      3.0.7-3          KDE - moving squares panel game
 i   kde-panel-worldwatch   3.0.7-3          KDE - worldclock panel applet
 i   kdeartwork3            3.0.7-3          KDE - additional artwork
 i   kdeedu3                3.0.7-3          KDE - educational software
 i   kdeedu3-shlibs         3.0.7-3          KDE - shared libraries used by kdeedu3 apps
 i   kdegames3              3.0.7-3          KDE - games
 i   kdegames3-common       3.0.7-3          KDE - shared libraries used by KDE games
 i   kdegraphics3           3.0.7-3          KDE - graphics
 i   kdenetwork3            3.0.7-3          KDE - networking
 i   kdenetwork3-common     3.0.7-3          KDE - shared libraries used by %N-shlibs
 i   kdenetwork3-misc       3.0.7-3          KDE - other miscellaneous network applications
 i   kdepasswd              3.0.7-3          KDE - password changer frontend
 i   kdessh                 3.0.7-3          KDE - ssh frontend
 i   kdetoys3               3.0.7-3          KDE - Toys
 i   kdeutils3              3.0.7-3          KDE - Misc. utilities
 i   kdf                    3.0.7-3          KDE - disk space GUI
 i   kdvi                   3.0.7-3          KDE - DVI print file previewer
 i   kedit                  3.0.7-3          KDE - simple text editor
 i   keduca                 3.0.7-3          KDE - create and revise form-based exams
 i   kenolaba               3.0.7-3          KDE - strategy board game
 i   kfax                   3.0.7-3          KDE - fax file viewer
 i   kfloppy                3.0.7-3          KDE - floppy disk formatter
 i   kformula               1.2.0-3          KDE - formula editor
 i   kfouleggs              3.0.7-3          KDE - PuyoPuyo clone
 i   kgeo                   3.0.7-3          KDE - interactive geometry
 i   kget                   3.0.7-3          KDE - download manager
 i   kghostview             3.0.7-3          KDE - postscript viewer
 i   khangman               3.0.7-3          KDE - hangman word game
 i   khexedit               3.0.7-3          KDE - hex editor
 i   kiconedit              3.0.7-3          KDE - icon editor
 i   kio-kmd                0.2-3            KIO module for running command-line utilities
 i   kit                    3.0.7-3          KDE - AIM chat client
 i   kiten                  3.0.7-3          KDE - Japanese reference and learning tool
 i   kivio                  1.2.0-3          KDE - flowchart program
 i   kjots                  3.0.7-3          KDE - small note taker
 i   kjumpingcube           3.0.7-3          KDE - tactical game
 i   klettres               3.0.7-3          KDE - multi-language alphabet learning aid
 i   klickety               3.0.7-3          KDE - tetris-like game
 i   klines                 3.0.7-3          KDE - Color Lines-like logic game
 i   kmahjongg              3.0.7-3          KDE - pick-up game based on the ancient mandarin Mah Jong
 i   kmail                  3.0.7-3          KDE - mail client
 i   kmathtool              3.0.7-3          KDE - a collection of small math tools
 i   kmessedwords           3.0.7-3          KDE - mind-training word game
 i   kmines                 3.0.7-3          KDE - minesweeper-like game
 i   kmoon                  3.0.7-3          KDE - moon phases
 i   kmplot                 3.0.7-3          KDE - mathematical function plotter
 i   knewsticker            3.0.7-3          KDE - news ticker
 i   knode                  3.0.7-3          KDE - nntp news reader
 i   knorskverbs            3.0.7-3          KDE - learn Norwegian verb conjugation
 i   kodo                   3.0.7-3          KDE - desktop mileage odometer
 i   koffice                1.2.0-3          KDE - Office Suite
 i   koffice-common         1.2.0-3          KDE - files used by all of KOffice
 i   kolf                   3.0.7-3          KDE - mini-golf game
 i   konquest               3.0.7-3          KDE - multi-player strategic war game
 i   kontour                1.2.0-3          KDE - vector drawing program
Continue in the next post....

Last edited by sao; 11-22-2002 at 04:58 AM.
sao is offline   Reply With Quote
Old 11-22-2002, 04:50 AM   #19
sao
Moderator
 
Join Date: Jan 2002
Location: Singapore
Posts: 4,237
Continued from above post...

Code:
 i   korn                   3.0.7-3          KDE - new mail notification
 i   kpaint                 3.0.7-3          KDE - graphic editor
 i   kpat                   3.0.7-3          KDE - collection of solitaire-like card games
 i   kpercentage            3.0.7-3          KDE - practice calculating percentages
 i   kpf                    3.0.7-3          KDE - personal fileserver
 i   kpoker                 3.0.7-3          KDE - poker card game
 i   kpovmodeler            3.0.7-3          KDE - POV-Ray 3D modeler and composer
 i   kpresenter             1.2.0-3          KDE - PowerPoint-like presentation app
 i   krdc                   3.0.7-3          KDE - remote desktop client (VNC)
 i   kregexpeditor          3.0.7-3          KDE - regular expression editor kpart
 i   kreversi               3.0.7-3          KDE - reversi clone
 i   krfb                   3.0.7-3          KDE - remote desktop server (VNC)
 i   kruler                 3.0.7-3          KDE - distance and color measurement
 i   ksame                  3.0.7-3          KDE - simple game inspired by SameGame
 i   kshisen                3.0.7-3          KDE - Shisen-So - a Mah Jong-like game
 i   ksim                   3.0.7-3          KDE - system monitor
 i   ksirc                  3.0.7-3          KDE - Internet Relay Chat client
 i   ksirtet                3.0.7-3          KDE - tetris clone
 i   ksmiletris             3.0.7-3          KDE - tetris clone
 i   ksnake                 3.0.7-3          KDE - snake race played against the computer
 i   ksnapshot              3.0.7-3          KDE - screenshot utility
 i   ksokoban               3.0.7-3          KDE - sokoban-like game
 i   kspaceduel             3.0.7-3          KDE - 2-player space arcade game
 i   kspread                1.2.0-3          KDE - spreadsheet
 i   kstars                 3.0.7-3          KDE - desktop planetarium
 i   ktalk                  3.0.7-3          KDE - UNIX chat client and server
 i   kteatime               3.0.7-3          KDE - tea timer
 i   ktimer                 3.0.7-3          KDE - timer
 i   ktouch                 3.0.7-3          KDE - touch-typing tutor
 i   ktron                  3.0.7-3          KDE - simple tron clone
 i   ktuberling             3.0.7-3          KDE - Mr. Potato Head-like game
 i   ktux                   3.0.7-3          KDE - tux-in-a-spaceship screensaver
 i   kugar                  1.2.0-3          KDE - business report viewer and creator
 i   kuickshow              3.0.7-3          KDE - slideshow application
 i   kverbos                3.0.7-3          KDE - spanish verb form study aid
 i   kview                  3.0.7-3          KDE - image viewer
 i   kvoctrain              3.0.7-3          KDE - vocabulary training tool
 i   kwikdisk               3.0.7-3          KDE - mount and unmount disks
 i   kwin4                  3.0.7-3          KDE - connect-4 clone
 i   kword                  1.2.0-3          KDE - word processoor
 i   kworldclock            3.0.7-3          KDE - international clock
 i   kworldclock-maps       3.0.7-3          KDE - extra maps for kworldclock
 i   kxmlrpcd               3.0.7-3          KDE - inter-process communcation server
 i   lisa                   3.0.7-3          KDE - network neighborhood browser
 i   lskat                  3.0.7-3          KDE - 2-player card game like Offiziersskat
 i   megami                 3.0.7-3          KDE - blackjack card game
 i   mosfet-liquid          0.9.5-6          Mosfet's "liquid" style for KDE
And that's a lot of packages.

KDE was one of the first things I installed after upgrading Fink for 10.2
(Sorry the list was too long to put in just one post)

Cheers...

Last edited by sao; 11-22-2002 at 05:16 AM.
sao is offline   Reply With Quote
Old 11-22-2002, 05:47 AM   #20
sao
Moderator
 
Join Date: Jan 2002
Location: Singapore
Posts: 4,237
And the same goes for Eterm in Jaguar:
Code:
i   aterm                  0.4.2-2          Afterstep XVT - a VT102 emulator
i   eterm                  0.9-1            Color VT102 terminal emulator
i   kterm                  6.2.0-2          X11terminal emulator that can handle multi-lingual text.
i   rxvt                   2.7.8-1          ouR XVT - a VT102 emulator for the X11

Cheers...
sao is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 05:35 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.