![](https://img-blog.csdnimg.cn/20201014180756913.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
shell
liuchenjane
这个作者很懒,什么都没留下…
展开
-
一个最简单的shell程序
创建一个shell脚本 vim hello_shell.sh 进入vim编辑器,按i进入插入模式 #!bin/zsh for ((i=0; i<10; i++)); do echo “hello_shell” done exit 0 按Esc退出插入模式,输入:wq退出,再为文件添加可执行权限 chmod 755 hello_shel原创 2016-10-11 21:31:57 · 5716 阅读 · 0 评论 -
195. Tenth Line
How would you print just the 10th line of a file?For example, assume that file.txt has the following content: Line 1 Line 2 Line 3 Line 4 Line 5 Line 6 Line 7 Line 8 Line 9 Line 10Your script原创 2017-01-01 20:46:17 · 367 阅读 · 0 评论 -
193. Valid Phone Numbers
Given a text file file.txt that contains list of phone numbers (one per line), write a one liner bash script to print all valid phone numbers.You may assume that a valid phone number must appear in one原创 2017-01-01 21:48:15 · 403 阅读 · 0 评论 -
shell中的条件判断式
if … thenif [ 条件判断式 ]; then #进行的命令工作内容fi #结束判断符号[]:在中括号[]内的每个组件都需要有空格键来分开;在中括号内的变量,最好以双引号括起来;在中括号内的常量,最好以单或双引号括起来 与&&和或||[ "$yn" == "Y" -o "$yn" == "y" ] <==> [ "$yn" == "Y" ]||[ "$yn" == "y原创 2016-12-22 21:31:01 · 431 阅读 · 0 评论 -
shell script 的执行
假设写的文件名是/home/dmtsai/shell.sh,如何执行?dmtsai是用户名。 直接命令执行: 1)绝对路径:使用/home/dmtsai/shell.sh来执行命令; 2)相对路径: 假设工作目录在/home/dmtsai/,则使用./shell.sh来执行; 3)变量“PATH”功能:将shell.sh放在PATH指定的目录内,例如:~/bin/。 以bash进程来执行原创 2016-12-19 09:30:14 · 585 阅读 · 0 评论 -
194. Transpose File
Given a text file file.txt, transpose its content.You may assume that each row has the same number of columns and each field is separated by the' ' character.For example, if file.txt has the fol原创 2017-01-07 19:02:21 · 333 阅读 · 0 评论