#! /bin/bashcat -s file # 压缩空白行cat -n file # 输出行号cat -T file # 输出制表符# 录放与回放终端会话# command: script / scriptreplay# 录制:script -t 2> timing.log -a output.session
# timing.log : 存储时序信息
# output.session: 存储命令输出
# -t : 将时序数据导入stderr
type commands;
# …
exit
# 回放:
scriptreplay timing.log output.session
# 视频广播:
# terminal1:
mkfifo scriptfifo
# terminal2:
cat scriptfifo
# terminal1:
script -f scriptfifo
commands
exit # you will get ‘Script done, file is scriptfifo’
# 一些有用的命令:
find -name “*.txt“ -type d -exec echo {} \;
cat file.txt | xargs -n 3
# 对来自标准输入的字符进行替换,删除以及压缩
tr [options] set1 set2
#sort / uniq
sort -nrk 1 data.txt
sort -k 2 data.txt
sort unsorted.txt | uniq -c # outpout repeat times
# 分割文件
split -b 10k data.file
# ls : data.file xaa xab xac xad …
split -b 10k data.file -d -a 4
# ls : data.file x0009 x0019 …
split [COMMAND_ARGS] PREFIX
# csplit
# ————————————————–
# 文件相关的命令:
dd if=/dev/zero of=/dev/null count=1 bs=1M
comm A.txt B.txt # 文件间的交集,并集,差集
chmod u=rwx g=rw o=r filename
# 粘滞位: 使得其用户组和其他用户即使拥有足够权限也无法删除该文件
chmod a+t dir_name
chattr +i filename # 写保护
chattr -i filename # 去除写保护
# 回环文件
dd if=/dev/zero of=test.img bs=100M count 100
mkfs.ext4 test.img
sudo mkdir /mnt/loopback
mount -o loop loopback.img /mnt/loopback
# losetup /dev/loop1 test.img
# mount /dev/loop1 /mnt/loopback
# 挂载iso文件
mkdir /mnt/iso
mount -o loop linux.iso /mnt/iso
# sync 立即应用更改
cat /dev/cdrom > image.iso # 光盘镜像创建
dd if=/dev/cdrom of=image.iso
mkisofs -V “label“ -o image.iso source_dir/
isohybrid image.iso # 混合iso iso -> usb
cdrecord -v dev=/dev/cdrom image.iso -speed 8
eject
eject -t
diff -u file1.txt file2.txt > version.patch
patch -p1 file1.txt < version.patch
ls -d */ # 仅列出目录
ls -F | grep “/$“
ls -l | grep “^d“
find . –type d -maxdepth 1 -print
# 目录定位
pushd dirname
pushd +3
popd dirname
popd +3
cd –
# 统计文件的行数,单词数,字符数
wc -l
wc -w
wc -c
wc -L file # 打印最长行的长度
tree dirname -P “*.sh“
tree dirname -I “*.sh“
tree -h
tree PATH -H http://localhost -o out.html
发表评论
要发表评论,您必须先登录。