最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

csh腳本語(yǔ)法實(shí)例

 更新時(shí)間:2014年11月24日 11:52:54   投稿:junjie  
這篇文章主要介紹了csh腳本語(yǔ)法實(shí)例,小編看起來(lái)和bash shell也差不太多,需要的朋友可以參考下

csh實(shí)例 參考:

復(fù)制代碼 代碼如下:

#!/bin/csh -vx
#csh -vx show the command before running to help debug

#just to check syntax
#csh -n $0

#argv
if ($#argv < 2) then
    echo "Sorry, but you entered too few parameters"
    echo "usage:  $0 arg1 arg2
    exit
endif
set arg1 = $1
set arg2 = #2

foreach i ($*)
   echo $i
end
  
#execute commands
echo "Hello there `whoami`.  How are you today?"
echo "You are currently using `hostname` and the time is `date`"
echo "Your directory is `pwd`"
whoami
hostname
date
pwd

#var
set name = Mark
echo $name
set name = "Mark Meyer" # if the string has space, must use ""
echo $name
# it means set to NULL
set name =
unset name
# get user input
set x = $< 
set current_user = `whoami`

#buildin vars
echo $user      # who am I?
echo $status    # a numeric variable, usually used to retun error codes

#Arithmetic variables
@ i = 2
@ k = ($x - 2) * 4
@ k = $k + 1
@ i--
@ i++

#array
set name = (mark sally kathy tony)
echo $#name    # num of the array
echo $name[1]
echo $name[4]
echo $name[2-3]
echo $name[2-]        # all elements from 2 to the end
echo $name[1-3]
echo $name[$i]
set name = ($name doran)
set name = (doran $name)
set name = ($name[1-2] alfie $name[3-])
shift name  # get rid of the frist element of the array
shift #if no argument is given, it will get rid of argv

#Expressions and operators
==        equal     (either strings or numbers)
!=        not equal     (either strings or numbers)
=~        string match
!~        string mismatch
<=        numerical less than or equal to
>=        numerical greater than or equal to
>         numerical greater than
<         numerical less than

-e file           file merely exists (may be protected from user)
-r file           file exists and is readable by user
-w file           file is writable by user
-x file           file is executable by user
-o file           file is owned by user
-z file           file has size 0
-f file           file is an ordinary file
-d file           file is a directory

!   -- negate                
&&  -- logical and
||  -- logical or

#if-else
# run cmd as if expression
if ({grep -s junk $1}) then 
   echo "We found junk in file $1"
endif
# check if the var is defined
if ($?dirname) then
    ls $dirname
endif

if (-e somefile) then
 grep $1 somefile
else
 echo "Grievous error!  Database file does not exist".
endif

#foreach
foreach i (*)
    if (-f $i) then
        echo "============= $i ==================="
        head $i
    endif
    if (-d $i) then
        (cd $i; headers)
    endif
end

#while
while ($#argv > 0)
    grep $something $argv[1]
end

@ n = 5
while ($n)
     # do something
     @ n--
end

#switch-case
switch ($argv[$i])
 case quit:
        break        # leave the switch statement
 case list:
        ls
        breaksw
 case delete:
 case erase:
        @ k = $i + 1
        rm $argv[$k]
        breaksw
endsw
   
#here document
grep $i <<HERE
John Doe   101 Surrey Lane    London, UK    5E7 J2K
Angela Langsbury   99 Knightsbridge, Apt. K4     Liverpool
John Major  10 Downing Street  London
HERE

cat > tempdata <<ENDOFDATA
53.3 94.3 67.1
48.3 01.3 99.9
42.1 48.6 92.8
ENDOFDATA

exit 0

相關(guān)文章

  • Linux 命令expect使用詳解

    Linux 命令expect使用詳解

    expect是由Don Libes基于Tcl語(yǔ)言開發(fā)的,是一種腳本語(yǔ)言,主要應(yīng)用于自動(dòng)化交互式操作的場(chǎng)景,借助Expect處理交互的命令,本文給大家介紹Linux 命令expect使用詳解,感興趣的朋友一起看看吧
    2023-11-11
  • win下調(diào)用putty執(zhí)行命令腳本分享

    win下調(diào)用putty執(zhí)行命令腳本分享

    這篇文章主要介紹了win下調(diào)用putty執(zhí)行命令腳本,可以利用這個(gè)實(shí)現(xiàn)一些自動(dòng)化的工作,需要的朋友可以參考下
    2014-03-03
  • Linux shell數(shù)組與關(guān)聯(lián)數(shù)組的用法實(shí)例

    Linux shell數(shù)組與關(guān)聯(lián)數(shù)組的用法實(shí)例

    今天小編就為大家分享一篇關(guān)于Linux shell數(shù)組與關(guān)聯(lián)數(shù)組的用法實(shí)例,小編覺得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來(lái)看看吧
    2019-02-02
  • linux中kvm的安裝及快照管理

    linux中kvm的安裝及快照管理

    這篇文章主要介紹了linux中kvm的安裝及快照管理的相關(guān)資料,需要的朋友可以參考下
    2016-12-12
  • linux 定時(shí)執(zhí)行shell、python腳本的方法

    linux 定時(shí)執(zhí)行shell、python腳本的方法

    這篇文章主要介紹了linux 定時(shí)執(zhí)行shell、python腳本的方法,本文給大家介紹的非常詳細(xì),感興趣的朋友跟隨小編一起看看吧
    2024-05-05
  • linux安裝php擴(kuò)展腳本分享

    linux安裝php擴(kuò)展腳本分享

    本文主要介紹了linux下安裝php擴(kuò)展的步驟,安裝是由shell批量執(zhí)行的,,需要的朋友可以參考下
    2014-03-03
  • Shell函數(shù)返回值方式

    Shell函數(shù)返回值方式

    本文主要介紹了Shell函數(shù)返回值方式,主要介紹了兩種返回方式,分別介紹了場(chǎng)景的使用和區(qū)別,具有一定的參考價(jià)值,感興趣的可以了解一下
    2022-08-08
  • linux 比較兩個(gè)文件夾diff不同 (diff命令, md5列表)

    linux 比較兩個(gè)文件夾diff不同 (diff命令, md5列表)

    這篇文章主要介紹了linux 比較兩個(gè)文件夾diff不同 (diff命令, md5列表),比較文件夾diff,可以直接使用diff命令,也可以比較文件md5列表,下面通過(guò)實(shí)例給大家介紹下,感興趣的朋友跟隨腳本之家小編一起學(xué)習(xí)吧
    2018-05-05
  • Shell腳本實(shí)用的六個(gè)技巧示例

    Shell腳本實(shí)用的六個(gè)技巧示例

    本文介紹Shell腳本實(shí)用的六個(gè)技巧示例:使用Shell腳本實(shí)現(xiàn)自動(dòng)化備份、使用Shell腳本實(shí)現(xiàn)定時(shí)任務(wù)、使用Shell腳本實(shí)現(xiàn)遠(yuǎn)程登錄服務(wù)器、使用Shell腳本自動(dòng)化部署應(yīng)用、使用Shell腳本實(shí)現(xiàn)快速部署開發(fā)環(huán)境、使用Shell腳本實(shí)現(xiàn)快速檢查服務(wù)器性能
    2023-11-11
  • 進(jìn)程狀態(tài)ps -ef中的e、f含義講解

    進(jìn)程狀態(tài)ps -ef中的e、f含義講解

    這篇文章主要介紹了進(jìn)程狀態(tài)ps -ef中的e、f含義講解,通過(guò)本文學(xué)習(xí)我們知道-e和-A都顯示有關(guān)其他用戶進(jìn)程的信息,包括那些沒(méi)有控制終端的進(jìn)程,-f顯示用戶id,進(jìn)程id,父進(jìn)程id,最近CPU使用情況,進(jìn)程開始時(shí)間等等,具體含義及更多命令跟隨小編通過(guò)本文學(xué)習(xí)
    2022-11-11

最新評(píng)論

永德县| 临安市| 陆良县| 虎林市| 长岛县| 锦屏县| 高台县| 新田县| 佳木斯市| 阿城市| 永宁县| 田林县| 鱼台县| 平顶山市| 化德县| 宾阳县| 中阳县| 峨眉山市| 广州市| 抚宁县| 开封县| 延安市| 泰宁县| 富顺县| 西青区| 宁国市| 稻城县| 香港 | 沐川县| 霞浦县| 小金县| 北宁市| 于都县| 石门县| 扶绥县| 小金县| 无为县| 汝南县| 攀枝花市| 会东县| 大足县|