Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Post History
How do I delete contents of a specific field, if it matches a pattern, and there is nothing else in the field? I have a several GB tsv file, and I am interested in a specific field (72). If it cont...
#1: Initial revision
How to delete contents of a specific field, if it matches a pattern and there is nothing else in the field
How do I delete contents of a specific field, if it matches a pattern, and there is nothing else in the field? I have a several GB tsv file, and I am interested in a specific field (72). If it contains hyphens, and *only* hyphens, then I want the hyphens deleted, leaving a blank field. I am using Ubuntu 20.04, with GNU awk v5. I've tried something like this: `awk 'BEGIN{FS=OFS="\t"}{gsub(/-/,"",$72)}1' file.tsv` But that also deletes the hyphens if there are other characters in the field too, which I do not want. E.g. `blah------` becomes `blah` but I want to leave it unchanged; but change `---------------` to nothing.