Content of file a.txt
Event: "112506400","17","2016/07/13-15-25-59.00",,,,,,,,,,,"112506400","115101234","02:00:00","pc","abc","4194","file_nam","F",,,"LA
",,"jk","123",,,,,,,,,,
I need a file which doesn't have $20 ( file_name ) redirected to asort.txt . Is there any short command as currently I am using the below
cat a.txt | grep Event: |awk -F, '{print $1","$2","$3","$4","$5","$6","$7","$8","$9","$10","$11","$12","$13","$14","$15","$16","$17","$18","$19","$21","$22","$23","$24","$25","$26","$27","$28","$29","$30","$31","$32","$33","$34","$35","$36","$37}'> asort.txt
cut
e.g.cut -d, -f1-19,21- a.txt
or (with GNU)cut -d, --complement -f20 a.txt
txr -e '(awk (:begin (set fs ",")) ((del [f 19])))
txr -e '(awk (:begin (set fs ",")) (t (del [f 19])))
(If some records don't have 20 or more fields and must be printed, we need an always-true condition!del
returns the prior value of the deleted place, which isnil
if there is no[f 19]
, andnil
is Boolean false).