Apolyton Archive  |  Preserved copy of the Apolyton Civilization Site and its forums as they stood in September 2005. Read-only; nothing here can be posted to or replied to.  |  Forum index |  About this archive |  The 1998–2001 UBB forums
Today on Apolyton WARDELL INTERVIEW PROMO A.C.S. HISTORY CHAPTER 4 GET CIV4 /w FREE PLUS! A.C.S. PHOTO GALLERY GET A.O.M. V1.1
Apolyton Civilization Forums
main| civ2| civ3| civ4| smac| ctp2| ron| moo3| galciv| galciv2| alt| about|
ApolytonPLUS | register | search | faq | new posts | pm (-/-) | upload | members
hall of fame new! | civgroups | civgroups news | interviews | the column | radio | chat | directory | news | store | PLUS
Apolyton Civilization Forums : Powered by vBulletin version 2.0.3 Apolyton Civilization Forums > Miscellaneous > Archive > Off-Topic-Archive > Help with unix commands
Show a Printable Version | Email This Page to Someone! | Receive updates to this thread | Report this to Apolyton news!

bottom of page
  
Author
Thread    < Last Thread     Next Thread > Post New Thread     Post A Reply
Kaak is offline Kaak
King
Lost
May 1999
time: 23:31
  Old Post 10-11-2003 19:58 Visit Kaak's homepage!
Edit/Delete Message Reply w/Quote
#1 Report this post to a moderator
Help with unix commands Support Apolyton buy from Amazon

I'm trying to use sed, and it asks me to print all lines where b-days are in November or December. The way the input file is set up,

sed -n '/^[^:]*:[^:]*:[^:]*:11/p' databook

gives me the b-days in november, i just don't know how to make it do an "or" to get both. any ideas?

Ari Rahikkala is offline Ari Rahikkala
King
Unreported loss of streaming in atomic read operation
Oct 1999
time: 07:31
  Old Post 10-11-2003 20:36 Visit Ari Rahikkala's homepage!
Edit/Delete Message Reply w/Quote
#2 Report this post to a moderator
Full PM-box? Change here!

I dunno how to do this portably, but in GNU sed you can use \| to match "either", like so:

/^[^:]*:[^:]*:[^:]*:\(11\)\|\(12\)/p

Provost Harrison is offline Provost Harrison
Emperor
The farce is strong with this one.
Feb 2000
time: 05:31
  Old Post 10-11-2003 21:06
Edit/Delete Message Reply w/Quote
#3 Report this post to a moderator
Increase the size of your Attachments

Thankyou for reminding me why I never have used Linux...

Paul Hanson is offline Paul Hanson
King
Dilbert
Aug 1999
time: 05:31
  Old Post 10-11-2003 21:10
Edit/Delete Message Reply w/Quote
#4 Report this post to a moderator
Avatar Enlargement: We've got the solution

Just because you're not l33t enough...

Urban Ranger is offline Urban Ranger
Apolyton Duke of Off-Topic

Donate to the Red Cross
The City State of Noosphere, CPA special envoy
May 1999
time: 13:31
  Old Post 10-11-2003 21:40
Edit/Delete Message Reply w/Quote
#5 Report this post to a moderator
Tired of ads?

quote:
Originally posted by Provost Harrison
Thankyou for reminding me why I never have used Linux...


That's just a regular expression. Not more complicated than most of the biochem stuff.

Q Cubed is offline Q Cubed
Prince
t3h y3ll0w p3ril
Apr 1999
time: 23:31
  Old Post 10-11-2003 21:43 Visit Q Cubed's homepage!
Edit/Delete Message Reply w/Quote
#6 Report this post to a moderator
Support Apolyton or Terrorists Win

paul hanson
provost harrison

both with eu markings...

confusing.

Paul Hanson is offline Paul Hanson
King
Dilbert
Aug 1999
time: 05:31
  Old Post 10-11-2003 21:46
Edit/Delete Message Reply w/Quote
#7 Report this post to a moderator
Support Apolyton, buy GURPS/ Alpha Centauri

You think that's bad? We both spend a lot of time in the same city as well.

Whaleboy is offline Whaleboy
Prince
Please make all cheques payable to Whaleboy
Jan 2003
time: 05:31
  Old Post 10-11-2003 22:49 Visit Whaleboy's homepage!
Edit/Delete Message Reply w/Quote
#8 Report this post to a moderator
Support Apolyton, buy Galactic Civilizations: Deluxe Edition

God I'm so glad I'm back to WinXP

Kaak is offline Kaak
King
Lost
May 1999
time: 23:31
  Old Post 10-11-2003 23:01 Visit Kaak's homepage!
Edit/Delete Message Reply w/Quote
#9 Report this post to a moderator
Lose 30 kilos (of popups)

thanks

Urban Ranger is offline Urban Ranger
Apolyton Duke of Off-Topic

Donate to the Red Cross
The City State of Noosphere, CPA special envoy
May 1999
time: 13:31
  Old Post 11-11-2003 08:35
Edit/Delete Message Reply w/Quote
#10 Report this post to a moderator
Support Apolyton, buy Civilization 2

quote:
Originally posted by Whaleboy
God I'm so glad I'm back to WinXP


For what? You don't need to know regex to use *nix.

Ari Rahikkala is offline Ari Rahikkala
King
Unreported loss of streaming in atomic read operation
Oct 1999
time: 07:31
  Old Post 11-11-2003 14:11 Visit Ari Rahikkala's homepage!
Edit/Delete Message Reply w/Quote
#11 Report this post to a moderator
Tired of ads?

Ah, of course, Doing it this way you don't need GNU extensions, AFAICT:

/^[^:]*:[^:]*:[^:]*:1[12]/p

Every time I use nonstandard extensions (such as the stuff GNU has added to so many *nix tools) anywhere I hear a little BSD daemon shouting at me about hypocrisy...

Fve Crathva is offline Fve Crathva
Settler

Apr 2001
time: 21:31
  Old Post 11-11-2003 14:18 Visit Fve Crathva's homepage!
Edit/Delete Message Reply w/Quote
#12 Report this post to a moderator
Support Apolyton, buy Civilization: The Boardgame

Out of curiosity, would this also work?

/^(.*?:){3}1[12]/p

SP

Last edited by Fve Crathva on 11-11-2003 at 15:18

Provost Harrison is offline Provost Harrison
Emperor
The farce is strong with this one.
Feb 2000
time: 05:31
  Old Post 11-11-2003 15:47
Edit/Delete Message Reply w/Quote
#13 Report this post to a moderator
Support Apolyton buy from Amazon

quote:
Originally posted by Paul Hanson
Just because you're not l33t enough...


That is true, I am always on time

Provost Harrison is offline Provost Harrison
Emperor
The farce is strong with this one.
Feb 2000
time: 05:31
  Old Post 11-11-2003 15:52
Edit/Delete Message Reply w/Quote
#14 Report this post to a moderator
Support Apolyton, buy GURPS/ Alpha Centauri

quote:
Originally posted by Paul Hanson
You think that's bad? We both spend a lot of time in the same city as well.


Except you spend your weekdays in Hull working (well, uni) and home in Lincolnshire on the weekends, whereas I spend my weekdays in Lincolnshire working and my weekends at home in Hull

Paul Hanson is offline Paul Hanson
King
Dilbert
Aug 1999
time: 05:31
  Old Post 11-11-2003 15:55
Edit/Delete Message Reply w/Quote
#15 Report this post to a moderator
Support Apolyton, buy Civilization III: Complete

Well, I'm actually spending more time in Hull this year. Not because I've developed an affinity for the place, but because my family drive me nuts.

Provost Harrison is offline Provost Harrison
Emperor
The farce is strong with this one.
Feb 2000
time: 05:31
  Old Post 11-11-2003 16:18
Edit/Delete Message Reply w/Quote
#16 Report this post to a moderator
Remove this text

Enjoy Hull...some of us are having to spend more time in Grimsby. It makes you appreciate the place

Pekka is offline Pekka
Chieftain
em seu burro dos pais!
Feb 2002
time: 07:31
  Old Post 11-11-2003 16:27
Edit/Delete Message Reply w/Quote
#17 Report this post to a moderator
Support Apolyton, buy Call to Power 2

kaak@kaak.net>I commaaand youu to obeyyy they woord of the Lord, which tells you to CHANGE DIRECTORY!

There are soem more basic commands, so what do you need?

Ari Rahikkala is offline Ari Rahikkala
King
Unreported loss of streaming in atomic read operation
Oct 1999
time: 07:31
  Old Post 11-11-2003 17:42 Visit Ari Rahikkala's homepage!
Edit/Delete Message Reply w/Quote
#18 Report this post to a moderator
Support Apolyton, buy Call to Power 2

Well, it was inevitable, I decided to start testing these regexes...

$ cat databook
0:04:01:10:wh00t
0:10:12:05:l33t-2003
0:01:01:01:666
0:04:15:11:324
0:04:15:12:k3wl

$ sed -n '/^[^:]*:[^:]*:[^:]*:11/p' databook
0:04:15:11:324

This one prints November's records, as it's supposed to...

$ sed -n '/^[^:]*:[^:]*:[^:]*:\(11\)\|\(12\)/p' databook
0:10:12:05:l33t-2003
0:04:15:11:324
0:04:15:12:k3wl

I'l figure out why this one produces wrong results later, if I can be bothered... (it probably picks up the 12 in the third column for some reason)

$ sed -n '/^[^:]*:[^:]*:[^:]*:1[12]/p' databook
0:04:15:11:324
0:04:15:12:k3wl

This one does exactly what it's supposed to do.

$ sed -n '/^(.*?:){3}1[12]/p' databook

And this one doesn't seem to do anything... however, a fixed version of it does:

$ sed -n '/^\(.*:\)\{3\}1[12]/p' databook
0:04:15:11:324
0:04:15:12:k3wl

As does a version that might be safer, or then not, I'm not really sure:

$ sed -n '/^\([^:]*:\)\{3\}1[12]/p' databook
0:04:15:11:324
0:04:15:12:k3wl

No, I for one have not understood sed's rules about what needs to be escaped and what not in regexes...

Provost Harrison is offline Provost Harrison
Emperor
The farce is strong with this one.
Feb 2000
time: 05:31
  Old Post 11-11-2003 20:20
Edit/Delete Message Reply w/Quote
#19 Report this post to a moderator
Support Apolyton, buy Galactic Civilizations

You're all such a bunch of nerds...

Ari Rahikkala is offline Ari Rahikkala
King
Unreported loss of streaming in atomic read operation
Oct 1999
time: 07:31
  Old Post 11-11-2003 20:41 Visit Ari Rahikkala's homepage!
Edit/Delete Message Reply w/Quote
#20 Report this post to a moderator
Support Apolyton buy from Amazon

I'm almost ashamed about the acts of l33tism I committed. I guess I've picked it up at the Gentoo forums where the user levels are in l33t, probably (hopefully) as a joke...

Whaleboy is offline Whaleboy
Prince
Please make all cheques payable to Whaleboy
Jan 2003
time: 05:31
  Old Post 11-11-2003 20:51 Visit Whaleboy's homepage!
Edit/Delete Message Reply w/Quote
#21 Report this post to a moderator
Support Apolyton buy from Amazon

What is l33t?

Provost Harrison is offline Provost Harrison
Emperor
The farce is strong with this one.
Feb 2000
time: 05:31
  Old Post 11-11-2003 21:13
Edit/Delete Message Reply w/Quote
#22 Report this post to a moderator
Support Apolyton or Terrorists Win

Very, very sad Whaleboy, very, very sad. You've proven your credibility by not knowing what it is

Urban Ranger is offline Urban Ranger
Apolyton Duke of Off-Topic

Donate to the Red Cross
The City State of Noosphere, CPA special envoy
May 1999
time: 13:31
  Old Post 12-11-2003 08:32
Edit/Delete Message Reply w/Quote
#23 Report this post to a moderator
Lose 30 kilos (of popups)

He's just playing dumb Rich.

Fve Crathva is offline Fve Crathva
Settler

Apr 2001
time: 21:31
  Old Post 12-11-2003 12:31 Visit Fve Crathva's homepage!
Edit/Delete Message Reply w/Quote
#24 Report this post to a moderator
Increase the size of your Attachments

^\([^:]*:\)\{3\}1[12] would be safer than ^\(.*:\)\{3\}1[12], but something can be said for using unsafe REs as an input debugging tool; does sed not know about non-greedy matching?

I think I'll stick to Perl. Oh, yes.

SP

Comrade Tassadar is offline Comrade Tassadar
Settler

Aug 2005
time: 05:31
  Old Post 12-11-2003 12:46 Visit Comrade Tassadar's homepage!
Edit/Delete Message Reply w/Quote
#25 Report this post to a moderator
Support Apolyton, buy GURPS/ Alpha Centauri

([3^4]*1:2(4)])$^¨b12

Fve Crathva is offline Fve Crathva
Settler

Apr 2001
time: 21:31
  Old Post 12-11-2003 13:09 Visit Fve Crathva's homepage!
Edit/Delete Message Reply w/Quote
#26 Report this post to a moderator
Remove this text

Sicko.

SP

  < Last Thread     Next Thread > Post New Thread     Post A Reply
All times are GMT. The time now is 05:31.
Apolyton Time is 00:31.
    top of page
Rate This Thread:
archivepost
Forum Jump:
Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is ON
vB code is ON
Smilies are ON
[IMG] code is ON
 




Contact Us - Apolyton Civilization Site - Support Us!

Building a better Apolyton through better information. Click here and take our poll!
Non-US visitors, click here!

Powered by: vBulletin Version 2.0.3
Copyright ©2000, 2001, Jelsoft Enterprises Limited.

Page generated in 0.0472 seconds (92.36% PHP - 7.64% MySQL) with 31 queries
Page Loading Time:

Support Apolyton: Amazon USA | Amazon UK | Amazon DE | Amazon FR |
Support Apolyton and get FREE PLUS, Buy from Chips&Bits: Galactic Civilizations | Galactic Civilizations: Deluxe Edition | Call to Power 2 | Civilization: The Boardgame | GURPS/ Alpha Centauri | Alpha Centauri | Civilization IV | Civilization III: Complete |


Front Page | Civilization IV | Civilization III | Civilization II | Call to Power II | Alpha Centauri | Master of Orion III
Rise of Nations | Galactic Civilizations | Galactic Civilizations II | Misc
Alt.Civs | Civ I | C:CtP I | About | News | Directory | Apolyton Store | Forums | Chat | Columns | Interviews | Newsletter
Scenario League | CSC | Clash of Civs | Spanish Site | CtP Maps | Cradle of Civ | WesW's Ctp1/2 Site | Civ3 Haven

apolyton.net | apolyton.com | civilization2.net | civilization3.net | civilization4.net | civilizationiv.info | calltopower.net | galciv.net | galciv2.net | moo3.net