BASHプログラミング
 Computer >> コンピューター >  >> プログラミング >> BASHプログラミング

Linux cdコマンド:ディレクトリの変更

このチュートリアルでは、Linuxでcdコマンドを使用して、シェル内で現在使用しているディレクトリを変更する方法について説明します。

以前、lsを使用してディレクトリを検索する方法について説明しました。しかし今、あなたはディレクトリの周りをナビゲートし始める必要があります。 cdで簡単にできます 、ディレクトリを変更します。簡単なことから始めましょう。cdのようなutilsでベイクされた簡単な方法について詳しく知るにはどうすればよいですか。 ?試してみる場合:

man cd

「CDの手動入力はありません」と報告されます。最も可能性が高い。 utilsでベイクする代わりに、ヘルプを使用してください。

help cd

CD構文

これで、役立つヘルプユーティリティを実行できました。次の出力があります。

cd: cd [-L|[-P [-e]] [admin@wsxdn.com]] [dir]
Change the shell working directory.


Change the current directory to DIR. The default DIR is the value of the
HOME shell variable.


The variable CDPATH defines the search path for the directory containing
DIR. Alternative directory names in CDPATH are separated by a colon (:).
A null directory name is the same as the current directory. If DIR begins
with a slash (/), then CDPATH is not used.


If the directory is not found, and the shell option `cdable_vars' is set,
the word is assumed to be a variable name. If that variable has a value,
its value is used for DIR.


Options:
-L force symbolic links to be followed: resolve symbolic
links in DIR after processing instances of `..'
-P use the physical directory structure without following
symbolic links: resolve symbolic links in DIR before
processing instances of `..'
-e if the -P option is supplied, and the current working
directory cannot be determined successfully, exit with
a non-zero status
admin@wsxdn.com on systems that support it, present a file with extended
attributes as a directory containing the file attributes


The default is to follow symbolic links, as if `-L' were specified.
`..' is processed by removing the immediately previous pathname component
back to a slash or the beginning of DIR.


Exit Status:
Returns 0 if the directory is changed, and if $PWD is set successfully when
-P is used; non-zero otherwise.

本音をいうと? CDヘルプのプリントアウトを確認したのはこれが初めてです。基本的な使い方を見てみましょう。

cd〜

チルダは、現在のホームディレクトリを参照する特殊文字です。 cd〜を使用すると、自宅に送られます。それが何であるかを知りたい場合:

echo $HOME

ホームディレクトリを印刷します。

cd ..

.. 特別なリファレンスでもあります。現在の作業ディレクトリの親ディレクトリを参照します。 cd ..と入力します 上記のディレクトリに移動します。次のように入力すると、上位レベルを追加できます。

cd ../..

それは2回進みます。

cd /

/ システムのルートを表します。 「cd/」と入力する そこに行く権限がある場合は、rootに移動します。

結論

それでおしまい!シェルを使用するための便利でシンプルな作業のヒント。


  1. Windows 10 の CMD でディレクトリを変更する方法

    すべての Windows 関連の問題は、コマンド プロンプト (CMD) という名前のプログラムで解決できる場合があります .コマンドプロンプトに実行可能なコマンドを入力して、さまざまな管理機能を実行できます。たとえば、 cd または ディレクトリを変更 コマンドは、現在作業しているディレクトリ パスを変更するために使用されます。たとえば、コマンド cd\windows\system32 は、ディレクトリ パスを Windows フォルダー内の System32 サブフォルダーに切り替えます。 Windows の cd コマンドは、chdir、 とも呼ばれます。 シェル スクリプトの両方で使

  2. コマンド ライン経由で Wi​​ndows 10 の CMD でディレクトリを変更する方法0

    コマンドプロンプトは、日付、時刻の変更、その他の問題の修復など、多くの目的に使用できる基本的なツールです。コマンド プロンプトは、実行ファイルの名前の後に cmd または cmd.exe とも呼ばれます。コマンド プロンプトの最初のプロトタイプは、Windows NT で起動されました。 PC の基本的な制御を目的として Therese Stowell によって作成されました。ただし、cmdでドライブを変更する方法としても使用できます。 パート 1. cd (ディレクトリの変更) コマンドとは パート 2. Windows 10 の CMD でディレクトリを変更する方法 パート 3. コマ