|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I have a sed problem. Is threre a way to transform rows like:
column Condition int into: column Condition { type = int; description = "" + "" + "" +; }; So need to transform 1 line to multiple lines. There should be \t -character in front of 'type' and 2 \t-characters in front of "" -rows. Thank you PS. If there is other UNIX program that makes it easier. Please tell and give the example. Last edited by masa567 : December 1st, 2005 at 05:56 AM. Reason: Maybe sed is not best |
|
#2
|
||||
|
||||
|
Take it a line at a time, use cut
Quote:
Quote:
|
|
#3
|
|||
|
|||
|
Quote:
Hello, I think the awk is better for this purpose. Try this: : awk ' NF == 3 { printf "%s %s\n", $1, $2 printf "{\n\ttype %s;\n", $3 printf "descritpiom = \"\" +\n" printf "\t\t \"\" +\n" printf "\t\t \"\" +;\n" printf "};\n" } ' <<EOF column condition int a b c EOF If you are on Solaris, put nawk instead of awk. This script transforms only the lines with exactly three fields separated by one or more white spaces. Ohter lines are silently ingnored. This is only to demonstrate the basic idea, you can add error messages for bad lines etc. I have used here the 'here document', you will input your data from the file, of course. Should you have any problems write again. Tested on Fedora Linux Regards zlutovsky |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > UNIX sed (please help!!) |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|