linux系统管理员处理日常任务的几个简单小方法

一、 从linux日志文件中读取数据并处理的脚本程序   g317

#!/bin/bash

exec 0< testfile
count=1

while read line
do
    echo "line #$count: $line"
    count=$[ $count + 1 ]
done

二、 快速清除文件(例:日志文件)中所有数据,而不必删除再重新创建 g324

cat /dev/null > testfile

三、查找文件夹

-type指明该name的属性

查找ipc文件夹

find ~/pkg/petalinux -type d -name ipc

四、从文档中删除空白行的快速方法

sed '/^$/d' file1.txt

命令行直接输入上面的命令,就可以删除空白行

猜你喜欢

转载自blog.csdn.net/xiang_shao344/article/details/82588670