uspTukubaiコマンドに関する様々な資料がここにあります。

 

 

魂内検索

DOCUMENTS

COMMAND

FORUM

UEC DOCS

VIDEO

 

Alphabetical list

(Video materials in preparation)

fsed(USP)

Name

fsed : Field oriented stream editer

Synopsis

Usage   : fsed [-e|-i] 's/<org>/<new>/<n>'... <file>

Version : Tue Jan  9 09:02:34 JST 2024

Edition : 1

Description

Substitute string <new> for string <org> within field <n> in

specified file <file>.  You may specify 'g' for field number meaning

for all fields.

The -e option allows you to use regular expressions.  The -i option

is similar to -e option except ignoring cases upon matching.

You can specify multiple substitue commands (s/<org>/<new>/<n>).  In

this case, -e/-i options are required each regular expression

substitue command.

Example 1

Convert "tokyo" to "TOKYO" in field 1, and convert "osaka" to "OSAKA"

in field 3.

$ cat data1

tokyo 1234 tokyo 5678

osaka 1234 osaka 5678

$ fsed 's/tokyo/TOKYO/1' 's/osaka/OSAKA/3' data1

TOKYO 1234 tokyo 5678

osaka 1234 OSAKA 5678

Example 2

Replace all 'tokyo' with 'yokohama'.

$ fsed 's/tokyo/yokohama/g' data1

yokohama 1234 yokohama 5678

osaka 1234 osaka 5678

Example 3

Using regular expressions.

$ cat data3

Tokyo 1234

tokyo 5678

TOKYO 7777

$ fsed -e 's/^[Tt]okyo$/New_York/1' data3

New_York 1234

New_York 5678

TOKYO 7777

New_York 1234

New_York 5678

New_York 7777

Example 4

Using regular expressions igoring cases.

$ fsed -i 's/tokyo/New_York/1' data3

New_York 1234

New_York 5678

New_York 7777

Example 5

Using multiple substitutes.

$ fsed 's/tokyo/yokohama/1' -i 's/tokyo/kawasaki/1' data3

kawasaki 1234

yokohama 5678

kawasaki 7777

Example 6

You may change the delmiter character of subustitue commands to

include '/' in the pattern string.  Any ASCII character can be used

for the delmiter character.

$ cat data6

001 /home/MANUAL/TOOL/fsed.txt

$ fsed 's,/,-,2' data6

001 -home-MANUAL-TOOL-fsed.txt

There is another way to include '/' into the pattern string, all '/'

characters are preceded by '\' character(backslash).

$ fsed 's/\//-/2' data6

001 -home-MANUAL-TOOL-fsed.txt