0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

改行コードを変数へ入れる(POSIX)

0
Last updated at Posted at 2021-04-17

こんにちは。
改行、タブなどのコードを変数へ入れました1。シェルスクリプトなどで使う目的です。

lf.sh
#!/bin/sh
LF=$(printf '\n_');LF=${LF%_}
TAB=$(printf '\t')
ESC=$(printf '\033')
Bash

Bash ならばシンプルな構文を持っています:

LF=$'\n'
TAB=$'\t'
ESC=$'\e'
  1. 参考:「シェルの文字列変数に改行を書き入れる方法

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?