Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
bash: jeden falschen wert auf einen bestimmten setzen
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
schrippe
Guru
Guru


Joined: 03 Mar 2004
Posts: 556
Location: Mülheim

PostPosted: Wed Aug 03, 2005 1:47 pm    Post subject: bash: jeden falschen wert auf einen bestimmten setzen Reply with quote

hallo,
ich muss in einem script die nicht erlaubten parameter abfangen.

dazu habe ich bereits den defaultwert per

IMPORTANT=$3
if IMPORTANT=${3:-1}
then
...
fi
zugewiesen.

wie fange ich jetzt alle anderen werte die man durch zufall einsetzen könnte so ab, das nur die zahlen 0 und 1 erlaubt sind?

alle anderen werte sollen dann auf standard 1 zurückgesetzt werden.

danke

ben
_________________
for i in $(seq 1 565); do echo 'A$i: entweder rechts fahren oder rechts überholen dürfen!';done
Back to top
View user's profile Send private message
nightmarez
Tux's lil' helper
Tux's lil' helper


Joined: 17 May 2004
Posts: 111
Location: FSV Mainz 05 ;)

PostPosted: Wed Aug 03, 2005 2:20 pm    Post subject: Reply with quote

mit case und *)
Code:

case $3 in
1) #zeugs von 1
2) #zeugs von 2
*) #alle anderen
esac
Back to top
View user's profile Send private message
schrippe
Guru
Guru


Joined: 03 Mar 2004
Posts: 556
Location: Mülheim

PostPosted: Thu Aug 04, 2005 9:47 am    Post subject: Reply with quote

gibts ne möglichkeit ein Textfile unter Linux so zu speichern, das es Windows Zeilenümbrüche hat?

Ich muss ein directory listing in den Datei umleiten. jetzt ist es aber nur ein durchgehender string.

danke
_________________
for i in $(seq 1 565); do echo 'A$i: entweder rechts fahren oder rechts überholen dürfen!';done
Back to top
View user's profile Send private message
dek
l33t
l33t


Joined: 16 May 2002
Posts: 657
Location: Germany

PostPosted: Thu Aug 04, 2005 10:07 am    Post subject: Reply with quote

unix2dos (bzw. dos2unix für die andere Richtung). Ist beides in portage.
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