小编Mea*_*ell的帖子

xargs grep忽略不符合查询的文件

关于使用xargs执行grep的快速问题.当我这样做时,我将显示一堆结果,这些结果来自不存在的文件,其间插入成功匹配搜索条件的文件,例如:

find . | xargs grep 'Cache'

grep: PT: No such file or directory
grep: Sans: No such file or directory
grep: Free: No such file or directory
grep: Font: No such file or directory
grep: License.txt: No such file or directory
Run Code Online (Sandbox Code Playgroud)

是否有一个可以传递的arg只能显示命中?

谢谢.

unix bash grep xargs

3
推荐指数
1
解决办法
1609
查看次数

Bash脚本正则表达式

我正在尝试匹配格式为4.6或2.8的字符串中的版本号.我将在我的.bashrc文件中的函数中最终使用以下内容来查找操作系统版本:

function test () {
    string="abc ABC12 123 3.4 def";
    echo `expr match "$string" '[0-9][.][0-9]'`
}
Run Code Online (Sandbox Code Playgroud)

但是,这与字符串中的3.4不匹配.任何人都能指出我在正确的方向吗?

谢谢.

regex unix bash

3
推荐指数
2
解决办法
2万
查看次数

用于检查前面字符的Bash搜索命令

不确定标题是否措辞正确,但我正在寻找一个bash命令来检查搜索词之前的字符.例如,如果我有一个包含单词列表的文件(lines.txt):

stackoverflow
stack overflow
stack over flow
Run Code Online (Sandbox Code Playgroud)

我需要用于搜索单词的命令over,但不包括stack紧接在其之前的任何结果.所以在上面的例子中只会输入最后两行.

我有grep -i 'over' lines.txt | grep -v 'stackover",但有没有更好的方法/选择写这个?我已经修改了一些其他选项(-E-P),并且一直在阅读负面的前瞻/后方,但无法让NOT部分工作.

unix bash grep

3
推荐指数
1
解决办法
55
查看次数

停止Apache CXF记录MultipartBody附件的二进制数据

我需要阻止CXF记录MultipartBody对象中的附件的二进制数据(由AbstractLoggingInterceptor出站消息中的抛出).当我添加my时LoggingInInterceptor,我设置setShowBinaryData为false,但这似乎不会阻止多部分消息中的二进制数据被记录.

我不确定是否需要创建自定义loggingInInterceptor,或者是否有一种配置现有拦截器的方法来截断它找到的任何二进制数据.停止它完全记录MultipartBody响应,或截断数据都是可接受的解决方案.

java logging cxf interceptor

3
推荐指数
1
解决办法
1670
查看次数

将本地 CQL 命令文件传递给 Cassandra Docker 容器

是否可以将 CQL 命令的本地文件传递给 Cassandra Docker 容器?

使用docker exec失败,因为它找不到本地文件:

me@meanwhileinhell:~$ ls -al
-rw-r--r--  1 me me  1672 Sep 28 11:02 createTables.cql

me@meanwhileinhell:~$ docker exec -i cassandra_1 cqlsh -f createTables.cql
Can't open 'createTables.cql': [Errno 2] No such file or directory: ‘createTables.cql'
Run Code Online (Sandbox Code Playgroud)

我真的不想打开 bash 会话并以这种方式运行脚本。

cql cassandra docker cqlsh

3
推荐指数
1
解决办法
3209
查看次数

按文件名排序查找命令

我希望仅按文件名而不是整个路径按字母顺序对 find 命令的输出进行排序。

假设我有一堆文本文件:

./d/meanwhile/in/b.txt
./meanwhile/c.txt
./z/path/with/more/a.txt
./d/mored/dddd/d.txt
Run Code Online (Sandbox Code Playgroud)

我正在寻找输出:

./z/path/with/more/a.txt
./d/meanwhile/in/b.txt
./meanwhile/c.txt
./d/mored/dddd/d.txt
Run Code Online (Sandbox Code Playgroud)

我试过了:

find . -type f -name '*.txt' -print0 | sort -t
find . -name '*.txt' -exec ls -ltu {} \; | sort -n
find . -name '*.txt' | sort -n
Run Code Online (Sandbox Code Playgroud)

...在其他排列中。

linux find alphabetical

3
推荐指数
1
解决办法
1594
查看次数

如何配置 Spring Batch 不自动创建批处理表来存储元数据?

我正在使用 JPA 在 PostGres 数据库上执行 CRUD 操作的 spring 批处理。我正在使用 Spring Boot 2.1.3。即使我添加了以下配置以禁用 Spring 批处理以使用我的 postgres 数据库来存储批处理作业元数据信息,但我收到“错误:关系“batch_job_instance”不存在”异常,如下所示。我也遵循了这里提到的解决方案。任何人都可以建议需要做哪些额外的事情?

hibernate.temp.use_jdbc_metadata_defaults=false
spring.batch.initialize-schema=never
spring.batch.initializer.enabled=false
Run Code Online (Sandbox Code Playgroud)

例外:

 Exception in thread "main" org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [SELECT JOB_INSTANCE_ID, JOB_NAME from BATCH_JOB_INSTANCE where JOB_NAME = ? and JOB_KEY = ?]; nested exception is org.postgresql.util.PSQLException: ERROR: relation "batch_job_instance" does not exist
  Position: 39
    at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:234)
    at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
    at org.springframework.jdbc.core.JdbcTemplate.translateException(JdbcTemplate.java:1444)
    at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:632)
    at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:669)
    at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:700)
    at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:712)
    at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:768)
    at org.springframework.batch.core.repository.dao.JdbcJobInstanceDao.getJobInstance(JdbcJobInstanceDao.java:148)
    at org.springframework.batch.core.repository.support.SimpleJobRepository.getLastJobExecution(SimpleJobRepository.java:297)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at …
Run Code Online (Sandbox Code Playgroud)

spring jpa spring-batch spring-boot

3
推荐指数
1
解决办法
8013
查看次数

使用另一个命名空间中的匿名命名空间中定义的变量

我在.cpp文件中有这个:

namespace {
    std::string CListName;
}

namespace EXAMPLE_NS {
    CListName = "ListName";
    ...
Run Code Online (Sandbox Code Playgroud)

但是Eclipse将该赋值强调为语法错误.我认为你不能使用来自另一个命名空间的匿名命名空间?

c++ namespaces

2
推荐指数
1
解决办法
705
查看次数

将byte []解密回String而不丢失数据

我编写了一个小应用程序来使用AES加密和解密字符串.这是代码:

import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;

public class AesEncryptionTest {
    static IvParameterSpec initialisationVector = generateInitialisationVector();
    static SecretKey encryptionKey = generateKey();
    static String plainText = "test text 123\0\0\0";

    public static void main(String [] args) {
        try {
            System.out.println("Initial Plain Text = " + plainText);

            byte[] encryptedText = encrypt(plainText, encryptionKey);
            System.out.println("Encrypted Text     = " + encryptedText);

            String decryptedText = decrypt(encryptedText, encryptionKey);
            System.out.println("Decrypted Text     = " + decryptedText);
        } catch (Exception e) {
            e.printStackTrace(); …
Run Code Online (Sandbox Code Playgroud)

java security encryption cryptography

1
推荐指数
1
解决办法
1791
查看次数

C等价于Java"Character.digit(hexText.charAt(i),16)"

我正在尝试使用C将十六进制字符串解码回二进制数据.我在Java中完成了这项工作,并且在C中具有等效的编码功能,但无法完全解码.看哪...

Java代码:

private static String encodeToHex(byte[] bytes) {
    StringBuilder stringBuilder = new StringBuilder();
    for (byte b : bytes) {
        stringBuilder.append(String.format("%02x", b & 0xff));
    }
    return stringBuilder.toString();
}

private static byte[] decodeFromHex(String hexText) {
    int length = hexText.length();
    byte[] data = new byte[length / 2];
    for (int i = 0; i < length; i += 2) {
        data[i / 2] = (byte) ((Character.digit(hexText.charAt(i), 16) << 4) + Character.digit(hexText.charAt(i + 1), 16));
    }
    return data;
}
Run Code Online (Sandbox Code Playgroud)

C代码:

void encodeToHex(const unsigned char *encryptedText, …
Run Code Online (Sandbox Code Playgroud)

c java hex

1
推荐指数
1
解决办法
792
查看次数

Spring Batch/Postgres:错误:关系“batch_job_instance”不存在

我正在尝试配置 Spring Batch 以使用 PostGres DB。我在我的build.gradle.kts文件中包含了以下依赖项:

implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("org.postgresql:postgresql")
Run Code Online (Sandbox Code Playgroud)

application.yml的 SpringBatch 模块包含以下内容:

spring:
  datasource:
    url: jdbc:postgresql://postgres:5432/springbatchdb
    username: postgres
    password: root
    driverClassName: org.postgresql.Driver
Run Code Online (Sandbox Code Playgroud)

docker-compose.yml

postgres:
    restart: always
    image: postgres:12-alpine
    container_name: postgres
    environment:
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=root
      - POSTGRES_DB=springbatchdb
    ports:
     - "5432:5432"
    volumes:
      - postgresql:/var/lib/postgresql
      - postgresql_data:/var/lib/postgresql/data
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试添加数据文件时,我在 SpringBatch Docker 容器和 PostGres 容器的日志中看到以下错误:

春季批次:

<<< Exception in method: org.meanwhileinhell.spring.batch.server.SpringBatchController.handle Error Message: PreparedStatementCallback; bad SQL grammar [SELECT JOB_INSTANCE_ID, JOB_NAME from BATCH_JOB_INSTANCE where JOB_NAME = ? and JOB_KEY = ?]; nested …
Run Code Online (Sandbox Code Playgroud)

postgresql spring-batch spring-boot

1
推荐指数
3
解决办法
2218
查看次数

ThymeLeaf:不等于 th:if 中的表达式

ThymeLeaf 非常新,但在我正在从事的项目中遇到了问题。在日志中收到以下错误:

Exception evaluating SpringEL expression: "!searchResults.results.empty"
Run Code Online (Sandbox Code Playgroud)

查看违规代码是:

<th:block th:if="${!searchResults.results.empty}">
Run Code Online (Sandbox Code Playgroud)

我认为感叹号 (!) 的位置不正确。我试过了:

<th:block th:if="${not searchResults.results.empty}">
Run Code Online (Sandbox Code Playgroud)

但同样的错误评估。有人可以帮助我如何取消支票吗?

javascript thymeleaf

0
推荐指数
1
解决办法
1万
查看次数

在 if 语句中使用 OR 来查看是否存在任一查询参数

我希望使用单个查询参数(例如age=gt:40name=eq:bob)来实现一个简单的过滤器。我想知道是否可以立即检查 GET 请求中是否存在name或?age一个例子可能会澄清我所追求的:

if ('age' or 'name') in request.GET:
Run Code Online (Sandbox Code Playgroud)

仅当使用第一个时才会匹配。当我使用查询参数到达端点时,name它与 true 不匹配。

我知道我可以做这样的事情:

if ('age' in request.GET) or ('name' in request.GET) :
Run Code Online (Sandbox Code Playgroud)

但这可能会很快增长并变得丑陋。

python django rest filtering query-string

0
推荐指数
1
解决办法
291
查看次数