導航:首頁 > 程序命令 > linux命令解釋器

linux命令解釋器

發布時間:2022-04-25 15:17:50

『壹』 linux的shell命令解釋器到底要做什麼

shell是一個命令解釋器。是計算機用戶和計算機操作系統內核之間的翻譯。計算機用戶在操作計算機是輸入的指令都是以人類語言來表示的。而計算機在內部進行信息處理是使用的都是二進制。所以shell會將用戶的輸入轉換成計算機能夠識別的信息。計算機處理完成後再有shell轉換成人能夠識別的信息輸出。

『貳』 Linux裡面env bash命令作用是什麼

env最常用的功能是查詢環境變數,直接輸入env即可,例如:

bash是Linux下的命令解釋器,目前CentOS,ubuntu,rhce默認都使用bash作為解釋器。

『叄』 windows系統的命令解釋器是cmd.exe那linux的命令解釋器是什麼

linux的命令解釋器叫shell,但linux又有多種不同的shell,常見的有Bourne shell(簡稱sh),C shell(簡稱csh),Korn shell(簡稱ksh)和Bourne Again shell(簡稱bash)。
ubuntu默認的shell是bash。
而且還有幾種不同的終端,但命令和腳本還是由shell來解釋和執行的。終端與shell沒有對應關系

『肆』 linux shell:這里的%% * 是什麼意思

${LINE%% *}的意思就是從LINE這個變數的值中,從後面開始以最長匹配刪去%%後面的表達式內容。

從用戶的shell看,wc -l的結果是行數+空格+文件名,用戶的匹配項是'空格*',那麼從後面開始的最長匹配就是行數後面的所有內容,也就是說,這個表達式最終的結果是產生命令行參數所帶文件的行數。

看一下man bash可以找到詳細說明,查找Parameter Expansion這段會看到:

${parameter%word}

${parameter%%word}

都是從parameter的最後開始刪除word所匹配的內容,%是最短匹配,%%是最長匹配。

(4)linux命令解釋器擴展閱讀:

實際上Shell是一個命令解釋器,它解釋由用戶輸入的命令並且把它們送到內核。不僅如此,Shell有自己的編程語言用於對命令的編輯,它允許用戶編寫由shell命令組成的程序。Shell編程語言具有普通編程語言的很多特點,比如它也有循環結構和分支控制結構等,用這種編程語言編寫的Shell程序與其他應用程序具有同樣的效果。

shell中的變數

1、常用系統變數

$ # :保存程序命令行參數的數目

$ ?:保存前一個命令的返回碼

$ 0 :保存程序名

$ * :以("$1 $2...")的形式保存所有輸入的命令行參數

$ @ :以("$1""$2"...)的形式保存所有輸入的命令行參數

2、定義變數

shell語言是非類型的解釋型語言,不象用C++/JAVA語言編程時需要事先聲明變數.給一個變數賦值,實際上就是定義了變數.

在linux支持的所有shell中,都可以用賦值符號(=)為變數賦值.

如:

abc=9 (bash/pdksh不能在等號兩側留下空格)

set abc = 9 (tcsh/csh)

由於shell程序的變數是無類型的,所以用戶可以使用同一個變數時而存放字元時而存放整數.

如:

name=abc (bash/pdksh)

set name = abc (tcsh)

在變數賦值之後,只需在變數前面加一個$去引用.如:

echo $name

『伍』 linux 命令中的sh是什麼意思

1、sh是linux中運行shell的命令,是shell的解釋器,shell腳本是linux中殼層與命令行界面,用戶可以在shell腳本輸入命令來執行各種各樣的任務。

要運行shell腳本,首選需要給shell腳本許可權,這里里以hello.sh文件為例,首先需要按下「crtl+shift+T」打開終端窗口:

『陸』 在Linux環境下模擬實現簡單命令解釋器

用別名來實現就行了,格式:ailas 你喜歡的別名="Linux 命令+參數"

如實現dir:alias dir="ls -la"
實現:alias ="cp"
實現del: alias del="rm -rf"
等等。

『柒』 linux操作系統中的命令解釋器有什麼特點

#include<iostream>
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
#include<time.h>//顯示當前時間函數用到的頭文件
#include<sys/stat.h>//創建目錄函數用到的頭文件,fn函數中參數
#include<sys/types.h>//創建目錄函數用到的頭文件
#include<unistd.h>//cd使用系統調用chdir函數,用到的頭文件
#include<dirent.h>//dir函數用到的頭文件
#include<ftw.h>//find中ftw系統函數用到的頭文件

usingnamespacestd;


voidDisplay();//主頁面顯示
DIR*exist_directory();//判斷目錄是否存在

intmain()
{
string_exit;//while循環出口判斷字元
Display();

while(_exit!="exit")
{
cout<<"33[01;33mHuangWenwei@33[0m";
//接收用戶輸入的第一個參數
cin>>_exit;

//重命名一個文件或目錄
if(_exit=="rename")
{
//opendir()系統函數的返回值
DIR*return_opendir;
charfilename1[20],filename2[20];
//接收用戶輸入的第二個參數(目錄名)
cin>>filename1;

//判斷目錄名是否存在
if((return_opendir=opendir(filename1))==NULL)
{
cout<<"thedirectorydoesn'texist! ";
/*用戶輸入三個參數,當執行這個if循環時
由於跳出rename這個循環而沒有執行cin>>filename2
但有第三個參數的存在,第三個參數賦給了while循環中的_exit變數
程序中的其他temp意思一樣
*/
stringtemp;
cin>>temp;
continue;//跳出rename判斷
}
//接收用戶輸入的第三個參數(文件名)
cin>>filename2;
//判斷文件是否存在
if(rename(filename1,filename2)==0)
{
cout<<filename1<<"successchangeto"<<filename2<<endl;
}
else
cout<<filename1<<"failurechangeto"<<filename2<<endl;

closedir(return_opendir);
}

//在指定的目錄及其子目錄中查找指定的文件
elseif(_exit=="find")
{
//指定的目錄
charspecifyDirectory[20];
//指定的文件
stringfilename;
//readdir()系統函數的返回值
structdirent*return_readdir;
//接收用戶輸入的第二個參數(目錄名)
cin>>specifyDirectory;
DIR*return_opendir=opendir(specifyDirectory);
//判斷指定的目錄名是否存在
if(return_opendir==NULL)
{
cout<<"thedirectorydoesn'texist! ";
stringtemp;
cin>>temp;
continue;
}
//接收用戶輸入的第三個參數(文件名)
cin>>filename;
//判斷文件是否存在
while((return_readdir=readdir(return_opendir))!=NULL)
{

if(return_readdir->d_name==filename)
cout<<filename<<"hasbeenfind.congratulation! ";
else
cout<<"Sorry,thefileyoufinddoesn'texitin"
<<return_readdir->d_name<<" ";
}
closedir(return_opendir);
}

//顯示當前所在目錄的路徑名
elseif(_exit=="pwd")
{
//系統函數getcwd的返回值
charreturn_getcwd[50];
getcwd(return_getcwd,sizeof(return_getcwd));
cout<<return_getcwd<<endl;
}

//改變當前工作目錄
elseif(_exit=="cd")
{
//opendir()系統函數的返回值
DIR*return_opendir;
//當前工作目錄
charfilename[20];
//接收用戶輸入的第二個參數(目錄名)
cin>>filename;
//判斷目錄是否存在
if((return_opendir=opendir(filename))==NULL)
cout<<"thedirectorydoesn'texist! ";
else
{
intreturn_chdir=chdir(filename);
cout<<"thecurrentworkingdirectoryis:"<<filename<<endl;
}
closedir(return_opendir);
}

//列出指定目錄名中的所有目錄及文件
elseif(_exit=="dir")
{
//readdir()系統函數的返回值
structdirent*return_readdir;
//opendir系統函數的返回值
DIR*return_opendir;
//指定目錄
charfilename[20];
//接收用戶輸入的第二個參數(目錄名)
cin>>filename;

return_opendir=opendir(filename);
//判斷目錄是否存在
if(return_opendir==NULL)
{
cout<<"thedirectorydoesn'texist! ";
continue;
}
//輸出文件中所有內容
while((return_readdir=readdir(return_opendir))!=NULL)
{
cout<<return_readdir->d_name<<endl;
}
closedir(return_opendir);
}

//新建目錄
elseif(_exit=="newdir")
{
charfilename[20];
cin>>filename;
//mkdir函數的返回值,其中10705是許可權位掩碼
intreturn_mkdir=mkdir(filename,00700);
cout<<filename<<"createdirectorysuccessful ";
}

//刪除目錄
elseif(_exit=="deldir")
{
DIR*return_opendir;//opendir()系統函數的返回值
charfilename[20];
cin>>filename;
if((return_opendir=opendir(filename))==NULL)
cout<<"thedirectorydoesn'texist! ";
else
{
rmdir(filename);
cout<<filename<<"deletesuccessful ";
}
closedir(return_opendir);
}

//顯示當前日期
elseif(_exit=="date")
{
//時間類型
time_ttimetype;
//時間格式
structtm*timeformat;
//獲取時間存於timetype函數原型:time_ttime(time_t*t);
time(&timetype);
//轉換為當地時間。函數原型:structtm*localtime(consttime_t*timer);
timeformat=localtime(&timetype);

//#include<time.h>函數原型:char*asctime(conststructtm*timeptr);
//轉為標准ASCII時間格式
cout<<"Thedateis:"<<asctime(timeformat);
}

//退出命令解釋程序
elseif(_exit=="exit")
{
cout<<"exittheprogram ";
}

//用戶錯誤輸入提醒
else
{
cout<<"pleaseinputcorrectcommand ";
}
}
return0;
}

//顯示界面
voidDisplay()
{
cout<<"33[01;31m@------------------------------------------@33[0m ";
cout<<"33[01;31m@@33[0m ";
cout<<"33[01;31m@dir<directoryorpath>Displaythefile@33[0m ";
cout<<"33[01;31m@cd<directoryorpath>ChangeDirectory@33[0m ";
cout<<"33[01;31m@newdir<directory>CreateDirectory@33[0m ";
cout<<"33[01;31m@deldir<directory>DeleteDirectory@33[0m ";
cout
<<"33[01;31m@
rename<OldFileName><NewFileName>renamethe
fileordirectory@33[0m ";
cout<<"33[01;31m@
find<directory>-name<FileName>Findthe
fileinspecified@33[0m ";
cout<<"33[01;31m@dateShowcurrentdate@33[0m ";
cout<<"33[01;31m@exitexittheprogram@33[0m ";
cout<<"33[01;31m33[0m";
}

『捌』 linux裡面bash是什麼

bash是一種命令處理器可以寫腳本語言 《linux就該這么學》不錯的linux自學書籍

『玖』 Linux命令解釋器——Shell

Shell是應用於Linux系統中的命令解釋器,其作用和Windows系統的命令提示符一樣。都是為當前用戶提供與系統內核進行交互操作的一種用戶界面。

『拾』 在linux中,命令解釋器是哪個 a,管道 b,分級文件系統 c,字元型處理器 d,shell

選d,shell

閱讀全文

與linux命令解釋器相關的資料

熱點內容
計算機編程知識 瀏覽:433
c語言編程軟體都有哪些 瀏覽:155
解壓一半可以取消嘛 瀏覽:119
住宅風水pdf 瀏覽:238
文件夾rundir什麼意思 瀏覽:971
戴爾電腦如何給硬碟加密 瀏覽:155
androidn版本特性 瀏覽:930
演算法期中試卷 瀏覽:939
php連接hbase 瀏覽:815
伺服器的威脅性應該是什麼等級 瀏覽:827
3d列印機的演算法原理 瀏覽:483
騰訊雲通信伺服器 瀏覽:891
minecraft最可怕伺服器地址 瀏覽:276
程序員選專業有必要嗎 瀏覽:32
如何重裝rpc伺服器 瀏覽:637
程序員必備的app 瀏覽:167
電動汽車加密幣 瀏覽:962
xp支持多少層文件夾 瀏覽:650
阿里雲伺服器防禦指標 瀏覽:895
cc網路編程學習 瀏覽:461