English 中文(简体)
Awk 删除纸面上的所有空白线(与指挥线无关)
原标题:Awk removing all blank lines in a script (not with command line)

我正在用LTeX将一只 file子变成一个pdf。 我的口号是这样:

BEGIN {printf "\documentclass[a4paper,notitlepage]{report}
" 
"\usepackage[utf8]{inputenc}
"
"\usepackage[francais]{babel}
"
"\usepackage[T1]{fontenc}
"
"\usepackage{hyperref}
"
"\usepackage{textcomp}
"
"\usepackage[left=1cm]{geometry}
"
..........
{print $1"
" 
$2"
" 
$3"
" 
$4"	"
$5"	" 
$6"	" 
$7"	" 
$8"	" 
$9"	" 
$10"
""\linebreak" 
......
$39"	"
$40;}

END {print "\end{document}";}

我找到了各种指挥官,去除指挥线上的空白线(awk NF , awk$0!~/^$/{print$0} ),并试图在文字末尾加上BEGIN和END声明的各种组合,但没有任何效果。

是否有任何帮助? 非常感谢......

最佳回答

Try adding !/^$/ before this line {print $1" " :

!/^$/ {print $1"
" 

<><>Edit>:

这里还有另一种做法:

BEGIN {
    ...
}
!/^[[:blank:]]*$/ {    # skip blank *input* lines
    output = $1"
" 
             $2"
" 
             ...
             $40
    # remove blank lines from *output*
    # it also removes trailing whitespace from each line
    gsub("([[:blank:]]*
)+", "
", output)
    print output
}
END {
   ...
}
问题回答

暂无回答




相关问题
Homework: Lisp items that appear more than once in a list

Given a list, I m trying to return a new one that has only the items that appear more than once in the first list I receive as a parameter. I have done the following: (defun myf (lista) (if (endp ...

Select duplicates with PHP & MySql for merging process

I wrote some code to select duplicates and group them using first and last names. I gather them into a multidimensional array and dedupe/merge them using jQuery/Ajax on the resulting page. I would ...

flagging duplicates in an array

After requesting some user pictures, I end up with an array like this: [ { label: "portrait", owner: "Jon" }, { label: "house", owner: "Jim" }, { label: "portrait", owner: "Jim" }, { ...

Fast way to eyeball possible duplicate rows in a table?

Similar: How can I delete duplicate rows in a table I have a feeling this is impossible and I m going to have to do it the tedious way, but I ll see what you guys have to say. I have a pretty big ...

How to merge duplicates in 2D python arrays

I have a set of data similar to this: # Start_Time End_Time Call_Type Info 1 13:14:37.236 13:14:53.700 Ping1 RTT(Avr):160ms 2 13:14:58.955 13:15:29.984 Ping2 RTT(Avr):40ms ...

How can I prevent duplicates in a WPF Listbox control?

I have a WPF listbox control that is declaratively bound to a textbox. The listbox s ItemsSource is an ObservableCollection that is built from an XML file. I can easily prevent duplicate entries in ...

marking duplicates in a csv file

I m stumped with a problem illustrated in the sample below: "ID","NAME","PHONE","REF","DISCARD" 1,"JOHN",12345,, 2,"PETER",6232,, 3,"JON",12345,, 4,"PETERSON",6232,, 5,"ALEX",7854,, 6,"JON",12345,, ...

热门标签