小编Jay*_*son的帖子

即使在更改.emacs之后,Emacs也会自动添加换行符

我目前在Mac上,并且我试图将Emacs设置为默认情况下不在文件末尾添加换行符,但我搜索的几乎所有内容都表示只需添加(setq require-final-newline nil).主目录中的emacs文件...这不起作用.我接下来要改变什么?

这就是.emacs文件现在的样子

(custom-set-variables
  ;; custom-set-variables was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
 '(gud-gdb-command-name "gdb --annotate=1")
 '(large-file-warning-threshold nil)
 '(require-final-newline nil))
(custom-set-faces
  ;; custom-set-faces was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file …
Run Code Online (Sandbox Code Playgroud)

emacs text-editor

12
推荐指数
1
解决办法
5783
查看次数

是否可以在awk中使用两个不同的字段分隔符并在变量中存储两个值?

我想我的一般问题是,是否可以给awk一个字段分隔符,将一个标记存储在变量中,然后给awk另一个字段分隔符,并将其中一个标记存储在第二个变量中,然后打印出来变量值?似乎变量存储对$ nth标记的引用,而不是值本身.

我想到的具体例子或多或少遵循这种形式:{动物},{种类}类

Cat, Felis catus MAMMAL
Dog, Canis lupus familiaris MAMMAL
Peregrine Falcon, Falco peregrinus AVIAN
...
Run Code Online (Sandbox Code Playgroud)

你希望它输出如下内容:

Cat MAMMAL
Dog MAMMAL
Peregrine Falcon AVIAN
...
Run Code Online (Sandbox Code Playgroud)

你想要的是符合形式的东西:{动物}类

将某些东西包含在{}中意味着它可以有任意数量的空格.

我最初的想法是我会有这样的事情:

cat test.txt | awk '{FS=","}; {animal=$1}; {FS=" "}; {class=$NF}; {print animal, class}; > animals.txt
Run Code Online (Sandbox Code Playgroud)

我希望变量"animal"存储逗号左边的内容,"class"来存储该动物的类类型,所以MAMMAL等等.但最终发生的事情是只有最后使用的Field分隔符是应用,所以这会破坏名称中有空格的东西,比如Peregrine Falcon等.

所以它看起来像

Cat, MAMMAL
Dog, MAMMAL
Peregrine AVIAN
Run Code Online (Sandbox Code Playgroud)

string bash awk parsing

4
推荐指数
1
解决办法
6952
查看次数

标签 统计

awk ×1

bash ×1

emacs ×1

parsing ×1

string ×1

text-editor ×1