How to split the fields of file based on field length
Hi,
Im trying to split the fields of file based on field length. The output should be written to same new file. Im trying like below but nothing is happening. Could some one suggest me what wrong I have done here or how can this be achieved? awk -F, '{if length($4) > 5 print > "newfile" ; if length($5) > 5 print > "newfile" ; else print > "oldfile"}' original_file Thanks in advance. |
Google (or duckduckgo search) for string handling and one of the engine names. Normal string handling by index or location will serve you well here.
Engines that are readily available in a non-development machine are BASH, awk, sed, perl, and there are others. I would do it directly in Bash unless you have other reasons that mandate awk. It is easier than you think. |
I do not use awk but I bet it is your formatting of the equation
http://www.unix.com/shell-programmin...using-awk.html |
I might mention python too.
|
Quote:
"if" requires brackets around the test - all of them. Then you can work on the likely logic error. |
All times are GMT -5. The time now is 08:56 PM. |