iis服务器助手广告广告
返回顶部
首页 > 资讯 > 服务器 >csh脚本语法实例
  • 285
分享到

csh脚本语法实例

语法脚本实例 2022-06-04 21:06:51 285人浏览 薄情痞子
摘要

csh实例 参考: #!/bin/csh -vx #csh -vx show the command before running to help debug #just to check syntax

csh实例 参考:

#!/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

--结束END--

本文标题: csh脚本语法实例

本文链接: https://www.lsjlt.com/news/18270.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • 有哪些csh脚本语法
    这篇文章主要介绍“有哪些csh脚本语法”,在日常操作中,相信很多人在有哪些csh脚本语法问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”有哪些csh脚本语法”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!cs...
    99+
    2023-06-09
  • 如何理解Csh的基本语法
    本篇内容介绍了“如何理解Csh的基本语法”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!在*unix系统中,常用的shell有sh,bash,...
    99+
    2023-06-09
  • VBS脚本基础语法实例讲解
    目录引言一、编辑VBS的相关软件二、变量的定义三、输入与输出1、输入2、输出四、判断语句五、循环语句1、do – loop 循环2、for – next 循环...
    99+
    2024-04-02
  • shell脚本编程中case语句的实例用法
    本篇内容介绍了“shell脚本编程中case语句的实例用法”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!case语句是用来实现多个if..e...
    99+
    2023-06-09
  • VBS入门脚本语言实例分析
    这篇文章主要介绍“VBS入门脚本语言实例分析”的相关知识,小编通过实际案例向大家展示操作过程,操作方法简单快捷,实用性强,希望这篇“VBS入门脚本语言实例分析”文章能帮助大家解决问题。一、VBS简介VBS是一种Windows脚本语言,全称是...
    99+
    2023-06-30
  • shell脚本实战之部署nginx脚本实例
    目录前言一键部署Nginx WEB平台(v1)版本一键部署Nginx WEB平台(v2)版本一键部署Nginx WEB平台(v4)版本: 增加IF语句使用信息总结前言 我们写脚本一定...
    99+
    2022-12-30
    nginx shell nginx项目部署 nginx 脚本
  • Javascript基本语法实例用法
    本篇内容介绍了“Javascript基本语法实例用法”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!代码&l...
    99+
    2024-04-02
  • HTML的脚本实例分析
    这篇文章主要介绍了HTML的脚本实例分析的相关知识,内容详细易懂,操作简单快捷,具有一定借鉴价值,相信大家阅读完这篇HTML的脚本实例分析文章都会有所收获,下面我们一起来看看吧。    ...
    99+
    2024-04-02
  • C#基本语法实例分析
    这篇“C#基本语法实例分析”文章的知识点大部分人都不太理解,所以小编给大家总结了以下内容,内容详细,步骤清晰,具有一定的借鉴价值,希望大家阅读完这篇文章能有所收获,下面我们一起来看看这篇“C#基本语法实例分析”文章吧。一.基础语法C#区分大...
    99+
    2023-06-29
  • MSSQL基本语法实例分析
    这篇文章主要讲解了“MSSQL基本语法实例分析”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“MSSQL基本语法实例分析”吧!刷新本地缓存Ctrl+Shift+R查询select&n...
    99+
    2023-06-29
  • linux shell常用的脚本语句语法
    这篇文章主要介绍“linux shell常用的脚本语句语法”,在日常操作中,相信很多人在linux shell常用的脚本语句语法问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”linux shell常用的脚本语...
    99+
    2023-06-13
  • GPU排队脚本实现空闲触发python脚本实现示例
    今天写了一个GPU排队脚本,事实上还是挺实用的。有的服务器是多用户使用,GPU的资源常常被占据着,很可能在夜间GPU空闲了,但来不及运行自己的脚本。如果没有和别人共享服务器的话,自己...
    99+
    2024-04-02
  • MSSQL基本语法及实例操作语句
    刷新本地缓存 Ctrl+Shift+R 查询 select *from [table] 修改 1、普通更新 UPDATE [table] set [字段]=[val...
    99+
    2024-04-02
  • python常用运维脚本实例
    file是一个类,使用file('file_name', 'r+')这种方式打开文件,返回一个file对象,以写模式打开文件不存在则会被创建。但是更推荐使用内置函数open()来打开一个文件 .首先open是内置函数,使用方式是open('...
    99+
    2023-01-31
    脚本 实例 常用
  • python运行脚本文件的三种方法实例
    目录python脚本执行的3种方法:方法一:交互模式直接执行语句方法二:通过脚本输出方法三:脚本中指定 python 路径,修改文件为可执行文件总结python脚本执行的3种方法: ...
    99+
    2024-04-02
  • VBS脚本基础语法是什么
    这篇文章主要讲解了“VBS脚本基础语法是什么”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“VBS脚本基础语法是什么”吧!一、编辑VBS的相关软件对于基于VBS的编程,我们可以直接使用记事本来...
    99+
    2023-06-30
  • 开发mysql单实例或多实例启动脚本
    单实例启动:mysqld_safe --user=mysql &停止:mysqladmin -u root -proot shutdown开发脚本#!/bin/bash #chkconfig:&nb...
    99+
    2024-04-02
  • C语言中switch语句基本用法实例
    目录switch语句:switch语句的基本格式C语言switch语句用法补充:用switch来给成绩等级 总结switch语句: 实际生活中,需要做出很多选择,大家都知道...
    99+
    2024-04-02
  • Shell脚本read用法实现
    目录1.概述2. read从标准输入读取值2.1 read选项2.2 IFS2.3 验证输入2.4 菜单1.概述 到目前为止,编写的脚本都缺少一个常用于大多数计算机程序的特性–交互性,或者说与用户互动的能力。...
    99+
    2023-01-12
    Shellread
  • python常用小脚本实例总结
    目录前言打印16进制字符串文件合并多线程下载图集多线程下载图片爬虫抓取信息爬虫多线程下载电影名称串口转tcp工具远程读卡器server端黑客rtcp反向链接调用c的动态库示例tcp的...
    99+
    2024-04-02
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作