我特别需要git将大多数文件扩展名视为二进制文件,除了一些扩展名.
我想将所有文件扩展名视为二进制文件,.pdf .doc .xls等,除了.txt .rb .py等纯文本文件.
我已经尝试过如下配置.gitattributes来看看它是如何工作的:
# cat .gitattributes
* binary
*.txt text
Run Code Online (Sandbox Code Playgroud)
我想也许配置文件中的顺序很重要,但似乎没有.使用上述配置,所有文件仍被视为二进制文件.
有没有办法配置.gitattributes或git以任何其他方式将所有文件作为二进制处理,除了一些例外?
更新1:
我尝试了下面描述的.gitattributes.有用!
# cat .gitattributes
*.txt crlf diff
* binary
# git diff
diff --git a/file b/file
index d929b94..bee5cb1 100644
Binary files a/file and b/file differ
diff --git a/file.txt b/file.txt
index 632ae98..93d22b0 100644
--- a/file.txt
+++ b/file.txt
@@ -1 +1,3 @@
Hey this is a .txt file
+Adding another line
+A new line
Run Code Online (Sandbox Code Playgroud)
更新2:
我相信crlf和text是相同的,即.gitattributes的以下两个配置是相同的:
# cat .gitattributes
*.txt crlf diff
* binary
# …Run Code Online (Sandbox Code Playgroud) jq是一个轻量级和灵活的命令行JSON处理器.
https://stedolan.github.io/jq/
是否有一个jq命令行工具或包装器,它允许您将输出管道输入并交互式探索jq,在一个窗格中使用JSON输入,并在另一个窗格中交互式更新结果,类似于jmespath.terminal?
我正在寻找类似于JMESPath终端jpterm
" 终端中的JMESPath探索工具"的内容"
https://github.com/jmespath/jmespath.terminal
我找到了这个项目,jqsh但它没有被维护,当我使用它时似乎会产生很多错误.
https://github.com/bmatsuo/jqsh
我使用过https://jqplay.org/,它是一个很棒的基于网络的jq学习工具.但是,我希望能够在shell中将命令的json输出管道jq传输到交互式,这允许我探索和试验jq命令.
提前致谢!
如何使用单词指示符和单词修饰符或类似的东西通过 bash shell 脚本自动执行以下操作?
root@server:/tmp# wget -q http://download.zeromq.org/zeromq-2.2.0.tar.gz
root@server:/tmp# tar -xzf !$:t
tar -xzf zeromq-2.2.0.tar.gz
root@server:/tmp# cd !$:r:r
cd zeromq-2.2.0
root@server:/tmp/zeromq-2.2.0#
Run Code Online (Sandbox Code Playgroud)
当我尝试类似下面的操作时,我会收到错误,因为单词指示符和单词修饰符在 bash 脚本中的工作方式似乎与在 shell 中的工作方式不同:
Bash shell 脚本示例 1:
#!/usr/bin/env bash
wget -q http://download.zeromq.org/zeromq-2.2.0.tar.gz && tar -xzf !$:t && cd !$:r:r
root@server:/tmp# ./install.sh
tar (child): Cannot connect to !$: resolve failed
gzip: stdin: unexpected end of file
tar: Child returned status 128
tar: Error is not recoverable: exiting now
Run Code Online (Sandbox Code Playgroud)
Bash shell 脚本示例 2:
#!/usr/bin/env bash
wget -q http://download.zeromq.org/zeromq-2.2.0.tar.gz
tar …Run Code Online (Sandbox Code Playgroud) # for i in {1..5} do echo "New File $i" > file$i done
-bash: syntax error near unexpected token `>'
Run Code Online (Sandbox Code Playgroud)
我尝试了上面的单行脚本,该脚本因上述错误而失败.我正在尝试自动化输入过程:
echo "New File" > file1
echo "New File" > file2
echo "New File" > file3
echo "New File" > file4
echo "New File" > file5
Run Code Online (Sandbox Code Playgroud)
我试图这样做而不创建一个脚本文件,如下面的工作:
#!/usr/bin/env bash
for i in {1..5}
do
echo "New File $i" > file$i
done
Run Code Online (Sandbox Code Playgroud)
这个脚本有效,但我希望能够在命令行的一行上做这样的事情.
我知道问题与重定向>到文件有关.我试图逃避>重定向一些其他的东西,谷歌搜索,但我没有想出一些有用的东西.
我希望能够在cli上单行执行此操作的原因是因为我希望能够不断更改文件的数量和内容以进行测试,我更愿意在命令行上执行此操作而不是编辑脚本文件.
我按照建议尝试了命令分隔符,并得到以下错误:
# for i in {1..5} do ; echo "New File …Run Code Online (Sandbox Code Playgroud)