I have a huge file, fixed width 500 characters wide. I would like to 'cut' roughly 125 of these characters out prior to FTPing. I have a cut command which works (some are ranges, some are single fields, but, it works). However, I would like to separate each of the parsed fields with a comma in the output file for ease of ORCL import.
Currently:
cut -c12-20,21-29,32......477-491 inputfile.txt>outputfile.txt
It runs, however, I would like to a comma between field20 and 21, 29 and 30 etc.
cut --output-delimiter="," -c12-20,21-29,32......477-491 inputfile.txt>outputfile.txt The original poster should always write the last response !!!
Let us know, if the problem is solved !!!
The cut command's output-delimiter is a GNU extension which is relatively new. If you aren't using using GNU, a way is to use awk to print out each field adding a comma: # UNTESTED cut -c12-20,21-29,32......477-491 inputfile.txt | awk ' { for(i=1; i<=NF; i++) printf("%s,", $i) print "\n" } ' > outputfile.txt
I'm sorry I didn't reply sooner, I actually found a different solution and have been working ridiculous hours... by the time I realized I had a response I had forgotten my login/psswd... just getting back to this now. This issue however is raising its ugly head again and I will be testing these solutions today. I appreciate the responses.
Again, thanks everyone for the responses... I've been re-introducing myself to awk recently, so I will give these a try.
The cut --output-deliminator="," is exactly what I needed, thank you. This solves a huge headache for me.
Yes (14) | ![]() | |
No (14) | ![]() | |
I don't know (15) | ![]() |