投资菜地

屋后的一亩三分绿色菜园地

2018-01-26

Cmd获取当前目录的绝对路径


rem CMD获取当前目录的绝对路径

@echo off
echo 当前盘符:%~d0
echo 当前盘符和路径:%~dp0
echo 当前批处理全路径:%~f0
echo 当前盘符和路径的短文件名格式:%~sdp0
echo 当前CMD默认目录:%cd%
echo 目录中有空格也可以加入""避免找不到路径
echo 当前盘符:"%~d0"
echo 当前盘符和路径:"%~dp0"
echo 当前批处理全路径:"%~f0"
echo 当前盘符和路径的短文件名格式:"%~sdp0"
echo 当前CMD默认目录:"%cd%"
pause

Linux命令

查看进程和删除进程

ps -ef | grep java 表示查看所有进程里 CMD 是 java 的进程信息 ps -aux | grep java -aux 显示所有状态 kill -9 pid

查看文件内容

cat 由第一行开始显示档案内容 tac 从最后一行开始显示 nl 显示的时候,顺道输出行号! od 以二进制的方式读取档案 more 和 less 一页一页的显示档案内容 less 与 more 类似,less 比 more 更好的是可以往前翻页

head tail 只看头和尾巴几行

find ./ grep -E ‘.zip’ xargs -t -I{} cp {} /usr/share/nginx/html/download -rf    
ps -ef grep process_name grep -v grep awk ‘{print $2}’ xargs kill -9 {}

sed -i ‘s/Search_String/Replacement_String/g’ Input_File sed -i ‘s/security.ubuntu.com/mirrors.aliyun.com/g’ /etc/apt/sources.list

sed -n ‘$p’ version.txt

删除30天前的日志

sudo find /var/log -type f -mtime +30 -exec rm -f {} \;

开源项目(更多)