Difference between revisions of "小代码大作用:电脑开荒代码"
Jump to navigation
Jump to search
Line 27: | Line 27: | ||
read text |
read text |
||
find . -iname "*$text*" |
find . -iname "*$text*" |
||
+ | </syntaxhighlight> |
||
+ | |||
+ | <syntaxhighlight lang="bash" line> |
||
+ | #!/bin/bash |
||
+ | # 用于比较文件 hash 值,确认文件是否为原版无更改 |
||
+ | |||
+ | echo "input origin > " |
||
+ | read origin |
||
+ | echo "input local > " |
||
+ | read local |
||
+ | |||
+ | if [ ${origin,,} = ${local,,} ]; then |
||
+ | echo "相等" |
||
+ | else |
||
+ | echo "有问题" |
||
+ | fi |
||
</syntaxhighlight> |
</syntaxhighlight> |
Revision as of 11:41, 19 September 2023
某一天,你拿到了一台新电脑。或者,某一天,你的电脑系统崩溃了。你需要从头配置一套从前习惯的工具链,那么,以下这些小代码,非常有用。请在你理解用处、并自担风险的情况下使用。
Windows 平台
1# set-network-private.ps1
2# 用于把公用网络改为私用网络,实现全屋共享。需以管理员权限运行:创建快捷方式,目标选本文件
3Set-NetConnectionProfile -InterfaceAlias "以太网" -NetworkCategory Private
1# shutdown.bat
2# 用于双击立即关机,省下从开始键点好几下才关机的工夫
3@echo off
4shutdown.exe /s /t 00
1# 右键创建快捷方式
2# 在桌面双击就可以直达知乎
3"C:\Program Files\Mozilla Firefox\firefox.exe" https://www.zhihu.com
Debian 平台
1#!/bin/bash
2# 用于查找本目录下的文件,不区分文件名大小写。包含查找的关键字就可以查到。不想换行该怎么写呢?其实用变量参数$1即可,但两行更方便,符合直觉
3read text
4find . -iname "*$text*"
1#!/bin/bash
2# 用于比较文件 hash 值,确认文件是否为原版无更改
3
4echo "input origin > "
5read origin
6echo "input local > "
7read local
8
9if [ ${origin,,} = ${local,,} ]; then
10 echo "相等"
11else
12 echo "有问题"
13fi