不使用git find,而使用git ls-files
在git中,无论是使用~grep~还是~ls-files~,都可以使用相同的语法来排除目录。请确保查阅相关文档!
指定文件的擴展名
只需要一种选择的中文释义:
如果使用通配符进行指定,它将在当前目录及其子目录中显示匹配的 git 管理文件。
$git ls-files *.css
src/components/Footer/style.css
src/components/templates/Container/style.css
# サブディレクトリで実行したけどフルパスで欲しい
$cd src/
$git ls-files *.css
components/Footer/style.css
components/templates/Container/style.css
$git ls-files --full-name components/*/*.css
src/components/Footer/style.css
src/components/templates/Container/style.css
以下是特定目录下的内容。
果然是通配符。当指定 src/components/* 时,它会显示下面的 git 管理文件。
$git ls-files src/components/*
src/components/index.js
src/components/Footer/style.css
src/components/templates/Container/style.css
确定阶层
果然是通配符
$git ls-files src/components/*/*.css
src/components/Footer/style.css
$git ls-files src/components/*/*/*.css
src/components/templates/Container/style.css
赠品
获取选项别名
$cat .gitconfig
[alias]
egrep = "grep --heading --break"
$git egrep reveal
package-lock.json
14163: "scrollreveal": {
14165: "resolved": "https://registry.npmjs.org/scrollreveal/-/scrollreveal-3.3.6.tgz",
package.json
63: "scrollreveal": "^3.3.6"
搜索今天产生的ERROR日志
当需要在日志存储位置(目录)中查找包含特定字符串的今天生成的日志文件时,可以使用以下命令。
$find /var/log/apache2 -type f -ctime -1 -print0 | xargs -0 grep -n ERROR
※ 可以设置为-ctime 0也可以。
find optiondesctypef(=file)やd(=directory)を指定ctimecreated time.
find -ctime -8
で一週間前から今日までに生成したもの、find -ctime +6
で一週間以上前に作成atimelast accessed time. 同上mtimelast modified time. 同上print0defaultで空白文字(改行、スペース、タブなど)で区切られるため、’hoge fuga’という名称をxargsに渡すと’hoge’と’fuga’に分解されてしまう。これをヌル文字(0×00、\0)に変換xargs -0上記を0x00で区切る