标签: shell

如何在IntelliJ IDEA中固定终端选项卡?

有没有办法保存终端选项卡的数量,名称和其他设置,以便在项目打开后在IDEA中自动打开它们?

可能是一些API通过shell以编程方式打开它?还是插件?

这是方便我有我在,像工作网络项目中的多个端子片build,start,karma,git,npm等,但它是很烦人的,我必须每次我打开一个项目时手动重新打开.

shell terminal intellij-idea

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

使用jq从ElasticSearch结果中的_source文档中提取数据

我正在阅读这个StackOverFlow讨论,将JSON转换为CSV,这似乎很棒,但是我无法使用基本的jq来工作。.我不确定我在做什么错。我已经尝试了基本的操作,但是我无法破解错误。这是我在Shell脚本中的ES查询

curl -XGET 'http://es-1:9200/data_latest/customer/_search?pretty' -H 'Content-Type: application/json' -d'
{
"_source": ["customer_app_version", "customer_num_apps", "customer_name","app_disk_size_bytes","app_memory_capacity_bytes"],
    "query": {
        "bool": {
            "must": [{
                "term": {
                    "is_app_customer": {
                        "value": "true"
                    }
                }
            }]
        }
    },
    "aggs": {
        "Customer_UUID": {
            "terms": {
                "field": "customer_uuid",
                "size": 100
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

“ Shell脚本输出

{
  "took": 8,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
  },
  "hits": {
    "total": 6171,
    "max_score": 1.8510876,
    "hits": [
      {
        "_index": "data_latest_v1",
        "_type": "customer",
        "_id": "0003245-4844-9015-1z2e-d4ae5234rd56",
        "_score": 1.8510876,
        "_source": …
Run Code Online (Sandbox Code Playgroud)

csv shell json curl jq

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

golang程序在调用linux shell命令后终止

我正在使用root权限执行以下golang程序(代码段):

  binary, lookErr := exec.LookPath("auditctl")
  if lookErr != nil {
    panic(lookErr)
  }
  env := os.Environ()

  args :=  []string{"auditctl", "-D"}
  execErr := syscall.Exec(binary, args, env)
  if execErr != nil {
    fmt.Println("error")
    panic(execErr)
  }

  fmt.Println("no error")
Run Code Online (Sandbox Code Playgroud)

因为我在系统中没有任何auditctl规则,该命令在终端中打印以下内容.这就像我直接输入shell时一样正常.

No rules
Run Code Online (Sandbox Code Playgroud)

除了不打印"错误"和"无错误".这意味着golang程序在syscall.Exec之后立即终止.这是怎么发生的?如何在syscall.Exec之后继续执行,因为我还有其他东西要在同一个程序中运行.

linux shell go

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

如何为bash文件生成的每个命令分隔输出?

假设我们有一个类似下面的bash脚本:

echo test
ls -alh
pwd
echo test2
Run Code Online (Sandbox Code Playgroud)

因此,文件上可以有任意数量的命令,每个命令产生或不产生自己的输出.

然后上面的文件像这样运行/bin/bash -xe test.sh,它将产生以下输出:

+ echo test
test
+ ls -alh
total 32
drwx------+  6 daniels  staff   204B Apr  3 23:33 .
drwxr-xr-x+ 64 daniels  staff   2.1K Apr  4 01:53 ..
-rw-r--r--@  1 daniels  staff   6.0K Apr  3 23:33 .DS_Store
drwxr-xr-x   5 daniels  staff   170B Mar 15 17:03 Todo
-rw-r--r--@  1 daniels  staff   282B Apr  3 20:39 test.py
-rw-r--r--@  1 daniels  staff    97B Apr  4 01:52 test.sh
+ pwd
/Users/daniels/Desktop …
Run Code Online (Sandbox Code Playgroud)

linux bash shell

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

使用shell脚本将当前日期/时间写入文件

我试图使用shell脚本将当前日期和时间写入文件.这是我到目前为止所拥有的

echo "$(date)" >> //home/user/Desktop/Scripts/Date Logs/datelog.txt

它会说它已经完成但在运行后没有任何内容打印到文件中.

linux shell sh

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

Gnome扩展-运行shell命令

我正在编写一个简单的扩展程序,通过单击扩展程序按钮来打开浏览器。我想知道是否有一个函数可以执行传递的shell命令作为参数。另外,如果有人可以为扩展开发提供一个很好的简单参考,那将真的很有帮助。

javascript linux shell gnome gnome-shell-extensions

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

bash脚本 - 无法在值中设置带双引号的变量

需要帮助修复此bash脚本以设置包含双引号值的变量.不知何故,我将此错误地定义为我的值,foo并且bar根据需要不用双引号括起来.

到目前为止我的脚本:

#!/usr/local/bin/bash
set -e
set -x

host='127.0.0.1'
db='mydev'
_account="foo"
_profile="bar"
_version=$1
_mongo=$(which mongo);

exp="db.profile_versions_20170420.find({account:${_account}, profile:${_profile}, version:${_version}}).pretty();";
${_mongo} ${host}/${db} --eval "$exp"

set +x
Run Code Online (Sandbox Code Playgroud)

输出显示:

+ host=127.0.0.1
+ db=mydev
+ _account=foo
+ _profile=bar
+ _version=201704112004
++ which mongo
+ _mongo=/usr/local/bin/mongo
+ exp='db.profile_versions_20170420.find({account:foo, profile:bar, version:201704112004}).pretty();'
+ /usr/local/bin/mongo 127.0.0.1/mydev --eval 'db.profile_versions_20170420.find({account:foo, profile:bar, version:201704112004}).pretty();'
MongoDB shell version: 3.2.4
connecting to: 127.0.0.1/mydev
2017-04-22T15:32:55.012-0700 E QUERY    [thread1] ReferenceError: foo is not defined :
@(shell eval):1:36
Run Code Online (Sandbox Code Playgroud)

我需要的是account:"foo",profile:"bar"用双引号括起来.

unix bash shell escaping quoting

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

当只有`read(2)`出现在Bash中的`whatis`时,如何看到`read`命令的手册页?

在Ubuntu Linux 16.04 LTS上,我想看到read用于命令的手册页,例如,将输入拆分为Bash shell中的数组.

但是,该whatis命令仅显示以下信息:

nlykkei@nlykkei-Ubuntu:~$ whatis read
read (2)             - read from a file descriptor
Run Code Online (Sandbox Code Playgroud)

但是read(2)手册页的部分仅记录系统调用(以及相关的C函数).

如何阅读read终端中使用的命令的手册页?

linux bash shell ubuntu

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

如何将变量重定向到文件但不在屏幕上显示

我有这个小代码来做一些数据处理.

#!/bin/sh
export DIR=`pwd`
if [ -d "$DIR" ] 
then
    for f in "$DIR"/HistoryData*; do
    if find "$f" -newermt 2017-03-13 ! -newermt 2017-03-14 
        then
            echo "$f" >> file
        fi
        done
else
    echo "$DIR does not exists"
fi
for f in $(cat < $DIR/file);do
        awk '/CO2/ && !/VAV/{ print $0 }' "$f" >> HistoryData_CO2
    done
Run Code Online (Sandbox Code Playgroud)

在线echo "$f" >> file我试图将变量写入文件,但它也显示在屏幕上的值.如何在控制台上抑制值并只写入文件

bash shell

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

在bash/linux中并行运行shell脚本

我有一个shell脚本job.sh.

内容如下:

#!/bin/bash

table=$1

sqoop job --exec ${table}
Run Code Online (Sandbox Code Playgroud)

现在当我做./job.sh table1

该脚本成功执行.

我在一个文件中有表名tables.txt.

现在我想循环遍历tables.txt文件并job.sh并行执行脚本10次.

我怎样才能做到这一点?

理想情况下,当我执行脚本时,我希望它在下面执行;

./job.sh table1
./job.sh table2
./job.sh table3
./job.sh table4
./job.sh table5
./job.sh table6
./job.sh table7
./job.sh table8
./job.sh table9
./job.sh table10
Run Code Online (Sandbox Code Playgroud)

有哪些选择?

linux bash shell cron crontab

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