YZ's Blog

A blog site recording my daily study.

Using Text Utilities to Do Chores

Emacs

There are a lot of high efficient edit functionalities incuded in Emacs. This section list some of them.

Keyboard macro

Applying a keyboard macro to a region

AWK

Share variable between shell and awk script

Use variable in awk script

1
gawk 'BEGIN{num=1}{print "\t{"$1", "$2 + 1", "$3+1", 40, "$5+1"},\t/* "num++" */"}' inputfile

SED

Usage

1
$ sed 'RANGE ACTION' file(s)

Using this command, we can execute some non-interactive batch edit specified by ACTION on lines specified by RANGE of file(or you may specify more than one file by wildcard of bash).

RANGE

Examples

  1. Merge two lines into one line

Bash array and string handling

Array

String

Comments