4
1

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 5 years have passed since last update.

新しくaliasを定義する際に「-bash: alias: ○○: not found」と出てしまう場合の解決法

Last updated at Posted at 2019-03-28

新しくaliasを定義しようとしたら、最初「-bash: alias: ○○: not found 」というエラーが出て
登録できませんでした。
その解決方法についての覚書きです。

エラー時の実行内容と結果

新規aliasの定義は「alias 名前=実行内容」(実行内容はシングルクォーテーションで囲う)でできるということなので、

$ alias lsa = 'ls -a'

と実行したところ、

-bash: alias: lsa: not found
-bash: alias: =: not found
-bash: alias: ls -a: not found

とエラーが出てうまく登録できませんでした。

解決策

「名前」と「=」、「=」と「実行内容」の間の空白を消して、

$ alias lsa='ls -a'

としたところ、無事終了。

aliasコマンドをしたところ、無事登録されていました。

$ alias

alias l.='ls -d .* --color=auto'
alias ll='ls -l --color=auto'
alias ls='ls --color=auto'
alias lsa='ls -a'

ポイント

新規aliasを定義する際は「alias 名前=実行内容」の「名前」と「=」、「=」と「実行内容」の間に空白を入れないようにすること

参考

Linux基本コマンドTips(97):【 alias 】コマンド/【 unalias 】コマンド――コマンドの別名(エイリアス)を登録する/削除する

4
1
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
4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?