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

csh腳本語法實例

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

csh實例 參考:

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

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

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

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

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

    linux中kvm的安裝及快照管理

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

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

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

    linux安裝php擴展腳本分享

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

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

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

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

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

    Shell腳本實用的六個技巧示例

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

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

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

最新評論

丹棱县| 锡林浩特市| 亚东县| 淮阳县| 沧源| 大宁县| 封开县| 天峻县| 无为县| 淄博市| 泌阳县| 平度市| 柘荣县| 溧水县| 根河市| 临汾市| 呼和浩特市| 平遥县| 屏东市| 盐亭县| 萨迦县| 澄迈县| 丽水市| 佳木斯市| 漠河县| 隆化县| 西吉县| 长沙县| 扶余县| 皋兰县| 资源县| 牡丹江市| 托克逊县| 泸定县| 通河县| 湖州市| 双柏县| 开原市| 儋州市| 开鲁县| 沾化县|