#!/bin/bash
read -p "please input a letter: " en
if [ “$en" = "hello" ]
then
echo "hello,how are you "
elif [ ! -n "$en" ]
then
echo "you must input a letter"
else
echo "the only permit input letter is hello"
fi
#include <stdioh>
#include <stdlibh>int main(int argc,char argv[])
{
int i;
char dst[128],pstr = argv[1];
for(i=0;pstr;i++)
dst[i] = toupper(pstr++);
dst[i] = '\0';
printf("%s\n",dst);
return 0;
}程序主体刚好7行。toupper是系统自带的库函数,用于实现把字母小写变大写;tolower是大写变小写。toupper的函数可以这样实现:Int toupper(int c){ if( c >= 'a' && c <= 'z' ) c -= ('a'-'A'); return c;}
#/bin/bash
#命令格式为脚本名 参数1 参数2
#alog-->源文件,放在脚本同目录
#先排序,可排除掉后面不需要的行,效率更高,但是遇到动辄上G的大文本,那就不建议用这种#方式了,sort或更费时,并且很占资源
sort -k 1 alog > alog1
cat alog1 | while read line; do
nu=`echo $line|awk '{print $1}'`
if [ $nu -ge $1 -a $nu -le $2 ];
then
echo $line
else
exit
fi
done
我知道了,这个程序本生没有问题,但是里面的两行单独是aaa的,要注意从行首开始,前面不要有空格。
你的问题是第一个aaa那行没有从行首开始,导致说是从42行有错,呵呵,刚试出来的
以上就是关于linux shell script 小程序问题全部的内容,包括:linux shell script 小程序问题、linux 把小写字母变为大写字母的小程序该怎么做、筛选类小程序(可以是linux命令行或Python)等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)