I have a file in which there are 54 fields, i want to grab the all the lines and send to a new file where filed18 has lenght greater than 14. How can i do it without if condition and faster way:
currently i am reading file line by line and comparing the length
read fileLine || break
oldDate=`echo $fileLine | cut -f18 -d "|" `
if [ "${#oldDate}" -gt 14 ]
then
`echo $fileLine >> $newFileName`
fi
can anyone suggest better and improved way. Thanks
---------- Post updated at 05:36 PM ---------- Previous update was at 05:35 PM ----------
is it possible that i replace the value of field18 with a variable value and then save the whole line in the new file, only if the length of field18 is greater than 14.
i think i was not clear enough to explain my problem, the problem is that i have one variable which has some value say value1 now i want to check each line of file, if the field18 is greater than 14 than replace whatever in the field18 with value1. I hope i am clear this time. Thanks