Operating System - HP-UX
1745832 Members
4441 Online
108723 Solutions
New Discussion

Unix korn shell scripting

 
Kerilyn O'Donnell
Contributor

Unix korn shell scripting

I left my scripting book at work and need a quick script to read in my text file and put the numbers in order which aren't necessarily at the beginning of the line. For instance, the text file looks like this:

Me9999ne
dog189
Horse8454

I want the new file to look like this:
Dog189
Horse8454
Me9999

Can someone please help me out here?

Thanks

 

 

P.S.This thread has been moved from  Archived Desktops and Workstations Boards>general to HP-UX > languages-HP Forums Moderator

1 REPLY 1
Thomas Schler_1
Trusted Contributor

Re: Unix korn shell scripting

Hi Kerilyn,

I'm sorry, but I think the korn shell is not a good tool for your special case. I had a look an sed, awk, and tr, but I think if one of these tools would solve your problem, a lot of brain storming has to be done unless you're a very good expert in using regular expressions. See regexp(5).

If you have perl, try to use it. You need a script that examines each occurence in your file letter by letter (testing with e.g. \d or \D), and produces the desired output, and sorting it with the sort function before printing.

Maybe, others have better ideas.

Thomas
no users -- no problems