linux shell

1

<!-- lang: shell -->
exec 3<input.txt
cat <&3
exec 4>output.txt
exec 5>>outputappend.txt

unalias   #删除别名
\ls           #别名转义

bash -nvx script.sh
#!/bin/bash -xv

# sub shell
(cd /bin; ls);
echo "$(ls; ps)"

echo {1..20}
echo {a..z}
for ((i=0; i<10; i++))

2

<!-- lang: shell -->
find . \(-name "*.txt" -o -name "*.pdf"\)
find . -regex
find . -newer file.txt -delete
find / \(-name "tools" -prune\) -o ...    #不包含tools, 跳过tools搜索
find . -print0 | xargs -0 rm -f        #将\0作为输入定界符
find src -type f -name "*.c" -print0 | xargs -0 wc -l

cmd1 | xargs -I {} cmd2 -p {} -a

seq 15 | echo $[$(tr '\n' '+')0]

#统计字符出现频次
echo 'ahahbaa' | sed 's/[^\n]/&\n/g' | sed '/^$/d' | sort | uniq -c | tr -d ' \n'

mktemp
echo $$
echo $RANDOM

file=sample.tar.gz
echo ${file%.*}
echo ${file%%.*}
echo ${file#*.}
echo ${file##*.}

expect

你可能感兴趣的:(linux shell)