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

 

 

魂内検索

DOCUMENTS

COMMAND

FORUM

UEC DOCS

VIDEO

 

Alphabetical list

(Video materials in preparation)

calsed(USP)

Name

calsed : sed "light"

Synopsis

Usage   : calsed    <org> <dst> <file>

          calsed -e <org> <dst> <file>

          calsed -f <script> <file>

Options : -n<string>

          -s<char>

Version : Mon Jan 22 09:17:08 JST 2024

Edition : 1

Description

calsed is a "light" version of the "sed" string replacement function.

Replaces the specified string with a specified string.  Unlike "sed"

you cannot use Regular Expressions.  If a file name is not specified

or if "-" is used, then calsed reads from the standard input.

If the replacement string is "@" then the string is converted to

null string.  To actually convert to "@" use the "-n" option.

The "-s" option specifies the character which is to be converted to

a space character within the replacement string.

The "-e" option specifies the next argument is the <org> string even

if it start with "-".

Example 1

Specify the replacement string directly.

$ cat data

<td>NAME</td>

<td>AGE</td>

$ calsed NAME usp data

<td>usp</td>

<td>AGE</td>

$ calsed NAME usp data | calsed AGE 25 - <-- Can be piped

<td>usp</td>

<td>25</td>

$ calsed NAME "usp lab" data  <-- If the replacement string has spaces

<td>usp lab</td>

<td>AGE</td>

$ calsed NAME @ data  <-- To specify NULL as the replacement string

<td></td>

<td>AGE</td>

$ calsed -nx NAME @ data  <-- Doesn't convert "@" to null

<td>@</td>

<td>AGE</td>

$ calsed -s_ NAME usp_lab data  <-- Specifies character to convert to space

<td>usp lab</td>

<td>AGE</td>

Example 2

"calsed" works properly even when a metacharacter is specified in a

shell variable.

(space, *, #, %, /, etc.)

In this case you must use double quotations ("$VAR").

Only when the replacement string is "@" it is converted to null.

$ NAME="*"

$ calsed NAME "$NAME" data

<td>*</td>

<td>25</td>

$ NAME="@"

$ calsed NAME "$NAME" data

<td></td>

<td>25</td>

Example 3

If the original string is started with "-", use "-e" to specify the

following argument is <org>.

$ cat data

aaa -bbb ccc

$ calsed -e -bbb xxx data

aaa xxx ccc

Example 4

Specify the search strings and replacement strings in a file.  The

file must be in "name" format.

before1 after1

before2 after2

before3 after3

Specify the original string and the converted string separated by a

single space.  The converted string can be null or contain spaces.

If the original string is "@" the original string is replaced with

null string.  This string can be changed using the "-n" option.

The "-s" option specifies a character in the converted string that

will be converted to a space.

$ cat script

NAME usp

AGE 25

$ calsed -f script data

<td>usp</td>

<td>25</td>

$ cat script2

NAME @

AGE

$ calsed -f script2 data

<td></td>

<td></td>

$ cat script3 <- Specify "[space]usp[space]lab[space]"

NAME  usp lab

AGE 25

$ calsed -f script3 data <- spaces can be converted as-is

<td> usp lab </td>

<td>25</td>

$ cat script4

NAME usp_lab

AGE 25

$ calsed -s_ -f script4 data <- specify character to be converted to space

<td>usp lab</td>

<td>25</td>

Note

Deprecated -d option (current -s option) is not supported.

Deprecated -i option (current -n option) is not supported.