awk delete from end
I have characters of the form "aa_b_c_d"
I need to repeatedly remove characters from the end,as in if(aa_b_c_d) do else if(aa_b_c) do else if(aa_b) do else if(aa) do etc. how can i do this in a script using awk..i just need to know how to split it like that.. |
don't understand what you trying to do. show a real example of an input, and show how you want the output to be.
|
My inputs are of the form {cluster of characters}_{cluster of characters}_ etc...
eg. aa_bc_dd_ff etc. Now, I should be able to repeatedly remove the final cluster of characters. if i supply aa_bc_dd_ff i should get aa_bc_dd if i supply aa_bc_dd i should get aa_bc so on hope thats clear |
Code:
$ a="aa_bc_dd_ff" |
What your really asking is how have awk print a range of fields; and apparently it's not a particularly easy thing to do. I found this page that discusses it:
http://awk.freeshell.org/RangeOfFields Unfortunately, it looks like the final link on the page for more suggestions is dead, though. |
All times are GMT -5. The time now is 02:57 PM. |