转载
sed :stream editor for filtering and transforming text 流编辑器文本转换工具sed不适用-i的情况下,不对源文件做修改,只将处理结果打印至屏幕,使用-i时将直接修改源文件,属于危险做法,用于脚本中修改配置文件,初学者不建议。sed使用方法: sed范围修改打印: &
tail :output the last part of files :输出文件尾部tail参数: -c,--bytes=K :output the last K bytes; alternatively, use -c +K to output bytes starting wi
head :output the first part of files :输出文件首部head选项: -c ,--bytes=[-]k :print the first K bytes of each file; with the leading ‘-’,print
more :file perusal filter for crt viewing :文件查看less :opposite of more :与more相反more file :分屏打印file并交还shell终端less file :打印file不会交还shell终端more | less :都支持用space向下翻屏,用b向上翻屏,用enter向下翻一行more中常用命令:&nbs
tac :concatenate and print files in reverse :链接并反向打印文件和cat打印正好相反,命令不常用,了解就好。
cat :concatenate files and print on the standard output :链接文件并标准打印输出,通常用于查看文件内容cat选项: -E ,--show-ends:display $ at end of each line :查看文件内容并每行以$结尾 -n ,--n
mv :move (rename) files :移动文件(和改名)mv选项: -f, --force :do not prompt before overwriting :覆盖之前不提示(强制) -n, --no-clobber :do not overwr
rm :remove files or directories :删除文件或目录rm选项: -f :--force :ignore nonexistent files, never prompt :忽略不存在文件,不提示 -i :prompt bef
file :determine file type :确定文件类型感觉file的参数比较鸡肋。
ls :list directory contents 列出目录内容ls选项 : -a :do not ignore entries starting with . :不忽略包含起始.的文件(隐藏文件) -A :do not list implied . and ..
touch :change file timestamps 修改文件时间戳,如果文件不存在,就创建文件touch选项: -c :do not create any files 不创建文件,只修改时间戳 -a :change only the access time 只改变访问时间&n
mkdir :make directories 如果目录不存在,就创建目录(Create the DIRECTORY(ies), if they do not already exist)mkdir选项: -m :--mode=MODE set file mode (a
cp:copy(复制) copy files and directories :拷贝文件或目录 Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY :拷贝源到目的,一个源时,拷贝‘目的’可以是文件名(可以不是原文件名,当不是
错误原因:由于变量初始化赋值为空,那么就成了 [ -ge "10"] 了,显然 [ 和 "10" 不相比较并且缺少了 [ 符号,所以报了这样的错误。解决办法:1、检查是否因为赋值语句写错而导致赋值为空2、赋值前加declare -i 变量=03、改成 if [[ $变量 -ge 10 ]] 再加一对 [][: -ge: unary operator expecte
Copyright © 2005-2025 51CTO.COM 版权所有 京ICP证060544号