Results 1 to 8 of 8
I need to modify the input entered by a user into a very specific format. I'm able to read the input, but I can't see how you can add to ...
- 08-18-2008 #1Just Joined!
- Join Date
- Aug 2008
- Posts
- 5
Modifying user input
I need to modify the input entered by a user into a very specific format. I'm able to read the input, but I can't see how you can add to it, or modify what they've keyed.
For example, I need to change the format of an HBA world wide id address from the users input of 100000c812f4f0c1 to 10.00.00.c8.12.f4.f0.c1 any ideas?
- 08-19-2008 #2Linux Newbie
- Join Date
- Jul 2008
- Posts
- 181
You can't seriously expect a helpful answer to a question that vague. Don't you think it might be relevant to mention the programming language you are using and how you are getting the user input in the first place?
- 08-19-2008 #3Just Joined!
- Join Date
- Aug 2008
- Posts
- 5
burschik,
Sorry about overlooking the obvious...
In a nutshell, I am writing a bash script that prompts an operator for the wwid address of the hba card(s) in their server. I'll need to modify their reply by changing the format, for example - 100000c812f4f0c1 to 10.00.00.c8.12.f4.f0.c1
Once I change the format, the script will add their server to the storage array (that will only acept the wwid address in this format).
- 08-19-2008 #4Linux Newbie
- Join Date
- Jul 2008
- Posts
- 181
Code:read input echo $input | sed 's/../&./g'
- 08-19-2008 #5Just Joined!
- Join Date
- Aug 2008
- Posts
- 5
Burschik,
Worked like a champ. Thanks very, very much!
- 08-19-2008 #6Just Joined!
- Join Date
- Aug 2008
- Posts
- 5
Burschik,
One last follow-up, the code returns an extra "." at the end of the string, how can I chop this off? From 10.00.00.00.c8.13.b2.1a. to 10.00.00.00.c8.13.b2.1a
- 08-20-2008 #7Linux Newbie
- Join Date
- Jul 2008
- Posts
- 181
Code:read input echo $input | sed 's/../&./g; s/\.$//'
- 08-20-2008 #8Just Joined!
- Join Date
- Aug 2008
- Posts
- 5
Thanks again, work perfectly!


Reply With Quote