Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
bash variable, sonderzeichen sollen weg -> tool ?
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Deutsches Forum (German)
View previous topic :: View next topic  
Author Message
stiwi
Apprentice
Apprentice


Joined: 20 Mar 2003
Posts: 266
Location: hamburg - germany

PostPosted: Tue Jan 25, 2005 9:51 pm    Post subject: bash variable, sonderzeichen sollen weg -> tool ? Reply with quote

ich schreibe gerade ein kleines bashscript, in dem mit immer wieder die spalten verrutschen, da in den strings sonderzeichen sind, die nicht angezeigt werden können. gibt es einen tool, das alles bis auf [a...z,0...9] aus strings löscht ? das geht doch bestimmt wieder mit sed :-), nur wer weiss wie ? :-) währe für hilfe sehr dankbar, da ich mit den regulären ausdrücken nicht so ganz klarkomme

danke
Back to top
View user's profile Send private message
DerMojo
Guru
Guru


Joined: 14 Aug 2003
Posts: 395
Location: Germany

PostPosted: Tue Jan 25, 2005 10:01 pm    Post subject: Reply with quote

Hi!

Guck dir mal "tr" an. Mit "tr -d '...'" kannst du bestimmte Zeichen löschen.
Für dich könnte folgendes interessant sein:
Code:
# echo -e "AbC\nDe99"
AbC
De99
# echo -e "AbC\nDe99" | tr -c -d '[a-z][A-Z][0-9]'
AbCDe99

"-c" komplementiert deine Angaben. du kannst auch einfachere Bereiche angeben, interessant wären

  • [:alnum:] all letters and digits
  • [:graph:] all printable characters, not including space


Siehe auch "man tr"

Daniel
_________________
To err is human, to forgive, beyond the scope of the Operating System.
Back to top
View user's profile Send private message
stiwi
Apprentice
Apprentice


Joined: 20 Mar 2003
Posts: 266
Location: hamburg - germany

PostPosted: Tue Jan 25, 2005 10:13 pm    Post subject: Reply with quote

danke, das klappt so. alle anzeigbaren zeichne sollten diese sein:

Code:

echo -e "Ab~C\nD,.e 9äöü9" | tr -c -d '[ -!][#-~][ä][ö][ü]'
Back to top
View user's profile Send private message
Dr_Pepper
Tux's lil' helper
Tux's lil' helper


Joined: 30 Jul 2004
Posts: 96
Location: /earth/europe/de/bawue/karlsruh'

PostPosted: Tue Jan 25, 2005 10:29 pm    Post subject: Reply with quote

Code:
echo "hallo wält" | sed 's/[^a-zA-Z0-9 ]//g'

_________________
[DrPepper]
--
Linux sex: unzip; strip; touch; finger; mount; fsck; more; yes; umount; sleep
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Deutsches Forum (German) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum