Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.
Status
Not open for further replies.
its working!!!
but now somethings wrong with the first headline and zeile1

Code:
curl https://www.rz.fh-hannover.de/etech/schoof/meldungen/export/meldungen.xml | grep -E '(ueberschrift|zeile)' | sed -E 's/\<zeile/  &/1' | sed -E 's/\<ueberschrift>(.+)\<\/ueberschrift>/\1/' |sed -E 's/\<.+>(.*)\<\/.+>/\1/'

Bildschirmfoto%202009-11-02%20um%2023.31.07.png
 
its working!!!
but now somethings wrong with the first headline and zeile1

Code:
curl https://www.rz.fh-hannover.de/etech/schoof/meldungen/export/meldungen.xml | grep -E '(ueberschrift|zeile)' | sed -E 's/\<zeile/  &/1' | sed -E 's/\<ueberschrift>(.+)\<\/ueberschrift>/\1/' |sed -E 's/\<.+>(.*)\<\/.+>/\1/'

Bildschirmfoto%202009-11-02%20um%2023.31.07.png

Not sure about this but it might have something to do with those "strange" characters: 'U' and 'o' with '..' on top.

Reoraganize your sed commands to not process the text inside <ueberschrift>:
instead of
sed -E 's/\<ueberschrift>(.+)\<\/ueberschrift>/\1/'
you can try and split it into 2:
sed -E 's/\<ueberschrift>//'
and
sed -E 's/\<\/ueberschrift>//'

that might work....
just a suggestions
 
it DID work! Thanks again!

...at least for the headline. But maybe I'll just have to do the same for "zeile"? Split it in "two"?

suppose I'd have to split this command right?
Code:
| sed -E 's/\<zeile/  &/1'
but, how? :)
 
woohoo, did it myself!

I just took care of every single tag with an own command:

Code:
curl https://..... | grep -E '(ueberschrift|zeile1|zeile2)' | sed -E 's/\<zeile/  &/1' | sed -E 's/\<ueberschrift>//' | sed -E 's/\<\/ueberschrift>//' | sed 's/<zeile1>//g' | sed 's/<zeile2>//g' | sed 's/<\/zeile2>//g' | sed 's/<\/zeile1>//g'
 
woohoo, did it myself!

I just took care of every single tag with an own command:

Code:
curl https://..... | grep -E '(ueberschrift|zeile1|zeile2)' | sed -E 's/\<zeile/  &/1' | sed -E 's/\<ueberschrift>/[1m/' | sed -E 's/\<\/ueberschrift>/[0m/' | sed 's/<zeile1>//g' | sed 's/<zeile2>//g' | sed 's/<\/zeile2>//g' | sed 's/<\/zeile1>//g'

Nicely done :)

One hint: i think u can replace these 4 commands
sed 's/<zeile1>//g' | sed 's/<zeile2>//g' | sed 's/<\/zeile2>//g' | sed 's/<\/zeile1>//g'
with only
sed 's/<.zeile.>//g'
'.' stands for "any printable character" (then why didn't it work with german characters??...)

Try and see if it works (i didn't :))
 
Nicely done :)

One hint: i think u can replace these 4 commands
sed 's/<zeile1>//g' | sed 's/<zeile2>//g' | sed 's/<\/zeile2>//g' | sed 's/<\/zeile1>//g'
with only
sed 's/<.zeile.>//g'
'.' stands for "any printable character" (then why didn't it work with german characters??...)

Try and see if it works (i didn't :))

thanks, I'll test is as soon as I'm home =)
 
Hello, I used this code


to take the "quote" from encarta. But sometime the "quote" is too long, it goes off of my screen.

Can someone fix it please. I don't know anything with apple script.

Hi,

first of all thank you for sharing that you don't know anything about apple script, but this is really not apple script, it's shell script. :p

second you should be a bit more specific on the "fix it" part. There's nothing wrong with the command itself so please let us know what you'd like happen (trim the output? split in 2 or more lines? ...?)

Cheers
 
Hi,

first of all thank you for sharing that you don't know anything about apple script, but this is really not apple script, it's shell script. :p

second you should be a bit more specific on the "fix it" part. There's nothing wrong with the command itself so please let us know what you'd like happen (trim the output? split in 2 or more lines? ...?)

Cheers

:D, my bad for apple or shell script

I think split in two lines is good.

thx you
 
Nicely done :)

One hint: i think u can replace these 4 commands
sed 's/<zeile1>//g' | sed 's/<zeile2>//g' | sed 's/<\/zeile2>//g' | sed 's/<\/zeile1>//g'
with only
sed 's/<.zeile.>//g'
'.' stands for "any printable character" (then why didn't it work with german characters??...)

Try and see if it works (i didn't :))

Okay, this doesn't work exactly, but when I type "..zeile.." instead of "<.zeile.>" it works....
dunno why =)

But Thanks a lot, now I think I'm able to put some nice RSS Feeds on my Desktop...
 
Okay, this doesn't work exactly, but when I type "..zeile.." instead of "<.zeile.>" it works....
dunno why =)

But Thanks a lot, now I think I'm able to put some nice RSS Feeds on my Desktop...

Maybe you need to call sed -e instead of just sed, or maybe put '\<' instead of just '<'.
Anyway i'm glad it's working.

If you subscribe to feeds then maybe you want to check a script that displays all your unread items from GoogleReader. If you do, check some pages back for a post of mine with a zip containing my scripts. :)

Enjoy
 
@digitallife

Ok, got a new one I can't figure out hoping the resident unix guru can.

currently using the standard script for the date

Code:
date +%A", "%B" "%d

which displays "Wednesday, November 04"

can we make a script that will remove the leading 0 for days 1-9 AND add st, nd, etc based on the final number? I think I can do an AppleScript but I'm curious if I can do it with Unix.
 
@digitallife

Ok, got a new one I can't figure out hoping the resident unix guru can.

currently using the standard script for the date

Code:
date +%A", "%B" "%d

which displays "Wednesday, November 04"

can we make a script that will remove the leading 0 for days 1-9 AND add st, nd, etc based on the final number? I think I can do an AppleScript but I'm curious if I can do it with Unix.


This will work, maybe it's not elegant, but it will work =)

Code:
date +%A", "%B" "%d | sed 's/01/1st/g' | sed 's/02/2nd/g' | sed 's/03/3rd/g' | sed 's/04/4th/g' | sed 's/05/5th/g'


This replaces every '01' with '1st', every '02' with '2nd' and so on.... from the fifth on you have to add the 'sed' commands yourself =)
 
@digitallife

Ok, got a new one I can't figure out hoping the resident unix guru can.

currently using the standard script for the date

Code:
date +%A", "%B" "%d

which displays "Wednesday, November 04"

can we make a script that will remove the leading 0 for days 1-9 AND add st, nd, etc based on the final number? I think I can do an AppleScript but I'm curious if I can do it with Unix.

Hi,

I see that tzippy has already solved the problem :)
Anyway I'd like to propose another solution. Both work so it's up to you..
If instead of
date +%A", "%B" "%d
you use
date "+%A, %B %-d" (changed the " but i don't think it's required)
Then the '0' in the day is removed
after that just add
Code:
 | sed -E 's/([^1]1)$/\1st/'| sed -E 's/([^1]2)$/\1nd/' |sed  -E 's/([^1]3)$/\1rd/' | sed -E 's/([0-9])$/\1th/'
(i think i made no mistakes here)
Explanaing:

the first sed command replaces everything that matches 'X1' where X is not number 1 (could space for example, or a 2) for 'X1st':
1 -> 1st
21 -> 21st
31 -> 31st
Note that 11 is not matched and does not become 11st but 11th (see last sed command)​

the second sed command replaces everything that matches 'X2' where X is not number 1 (could space for example, or a 2) for 'X2nd':
2 -> 2nd
22 -> 22nd
Note that...bla bla bla (see above :))​

the third sed command does the same for 3rd...

the last sed command replaces every digit followed by an endOfLine with tha digit + 'th'
Since we had added the 'st', 'nd', 'rd' before, the only digits that are followed by endOfLine are the remaining days.

hope everything is explained :)

ps: needed to change it because it was putting 21th instead of 21st

if you try for every day you get this. I think it's correct (ignore the weekday in this output):
Code:
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31; do date "+%A, %B $i"  | sed -E 's/([^1]1)$/\1st/'| sed -E 's/([^1]2)$/\1nd/' |sed  -E 's/([^1]3)$/\1rd/' | sed -E 's/([0-9])$/\1th/' ;done
Wednesday, November 1st
Wednesday, November 2nd
Wednesday, November 3rd
Wednesday, November 4th
Wednesday, November 5th
Wednesday, November 6th
Wednesday, November 7th
Wednesday, November 8th
Wednesday, November 9th
Wednesday, November 10th
Wednesday, November 11th
Wednesday, November 12th
Wednesday, November 13th
Wednesday, November 14th
Wednesday, November 15th
Wednesday, November 16th
Wednesday, November 17th
Wednesday, November 18th
Wednesday, November 19th
Wednesday, November 20th
Wednesday, November 21st
Wednesday, November 22nd
Wednesday, November 23rd
Wednesday, November 24th
Wednesday, November 25th
Wednesday, November 26th
Wednesday, November 27th
Wednesday, November 28th
Wednesday, November 29th
Wednesday, November 30th
Wednesday, November 31st
 
Hi,

I see that tzippy has already solved the problem :)
Anyway I'd like to propose another solution. Both work so it's up to you..
If instead of
date +%A", "%B" "%d
you use
date "+%A, %B %-d" (changed the " but i don't think it's required)
Then the '0' in the day is removed

etc........

=) Thanks digital and zippy. I was sure there was a way to make it work with sed but I still wasn't getting the text substation to work out.

The -d isn't working though...

date "+%A, %B %-d" returns the date with -d for the day. I'll mess with it and see if I can get it right before I need to leave this morning.

Thanks again guys!
 
=) Thanks digital and zippy. I was sure there was a way to make it work with sed but I still wasn't getting the text substation to work out.

The -d isn't working though...

date "+%A, %B %-d" returns the date with -d for the day. I'll mess with it and see if I can get it right before I need to leave this morning.

Thanks again guys!

Good to hear:) and sorry about the '-d'.. it works in Linux which is the closest thing to macOSX that i have at work :)
(you can add sed -E 's/0([1-9])/\1/' just after the date command to remove it)
 
digitallife, I hope you realize that you're the one who revealed the power of this tiny tiny "sed" to me :)
And at a time where I definately were supposed to study :)
 
digitallife, I hope you realize that you're the one who revealed the power of this tiny tiny "sed" to me :)
And at a time where I definately were supposed to study :)

Hi, glad to hear :D
Sed is indeed very powerfull!
Now regarding your sudies...
...
...
sorry :( lol (unless you need to study about sed. In that case it'll be 100€ :p)
 
Status
Not open for further replies.
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.